From 5503f110a82ba9d4a4b694b41752897a09eec666 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 7 Aug 2006 17:59:47 +0000 Subject: [PATCH] changed ADMIN_area_code_populate.pl to DBI git-svn-id: svn://192.168.202.10@124 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/ADMIN_area_code_populate.pl | 18 +++++++++--------- agc_2-X/trunk/bin/AST_VDremote_agents.pl | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/agc_2-X/trunk/bin/ADMIN_area_code_populate.pl b/agc_2-X/trunk/bin/ADMIN_area_code_populate.pl index 1bbc129c..0a01c2bb 100644 --- a/agc_2-X/trunk/bin/ADMIN_area_code_populate.pl +++ b/agc_2-X/trunk/bin/ADMIN_area_code_populate.pl @@ -1,28 +1,26 @@ #!/usr/bin/perl -# ADMIN_area_code_populate.pl version 1.1.12 for Perl +# ADMIN_area_code_populate.pl version 0.3 *DBI-version* # # Copyright (C) 2006 Joe Johnson,Matt Florell LICENSE: GPLv2 # # Description: # server application that allows load areacodes into to asterisk list database # -# # CHANGES # 60615-1514 - Changed to ignore the header row +# 60807-1003 - Changed to DBI # -use lib ".\\",".\\libs", './', './libs', '../libs', '/usr/local/perl_TK/libs', 'C:\\AST_VICI\\libs'; use Time::HiRes ('gettimeofday','usleep','sleep'); # needed to have perl sleep in increments of less than one second -use Net::MySQL; +use DBI; ### Make sure this file is in a libs path or put the absolute path to it require("/home/cron/AST_SERVER_conf.pl"); # local configuration file if (!$DB_port) {$DB_port='3306';} -$dbh = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") - or die "Couldn't connect to database: $DB_server - $DB_database\n"; - +$dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass") + or die "Couldn't connect to database: " . DBI->errstr; $slash_star = '\*'; @@ -50,7 +48,7 @@ $slash_star = '\*'; { chop($ins_stmt); chop($ins_stmt); - $dbh->query($ins_stmt) || die "can't execute query: |$ins_stmt| $!\n"; + $affected_rows = $dbhA->do($ins_stmt) || die "can't execute query: |$ins_stmt| $!\n"; $ins_stmt="insert into vicidial_phone_codes VALUES "; print STDERR "$pc\n"; } @@ -60,8 +58,10 @@ $slash_star = '\*'; chop($ins_stmt); chop($ins_stmt); - $dbh->query($ins_stmt); + $affected_rows = $dbhA->do($ins_stmt); $ins_stmt="insert into vicidial_phone_codes VALUES "; print STDERR "$pc\n"; +$dbhA->disconnect(); + exit; \ No newline at end of file diff --git a/agc_2-X/trunk/bin/AST_VDremote_agents.pl b/agc_2-X/trunk/bin/AST_VDremote_agents.pl index 0e9f2b7c..40558a0e 100644 --- a/agc_2-X/trunk/bin/AST_VDremote_agents.pl +++ b/agc_2-X/trunk/bin/AST_VDremote_agents.pl @@ -469,7 +469,7 @@ while($one_day_interval > 0) &event_logger; - $dbhA->close; +$dbhA->disconnect(); if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";}