#!/usr/bin/perl use DBI; use IO::File; #use strict; my $db = "CAMDPAMS"; my $host = "192.168.8.10"; #my $file = "GeoIPCountryWhois.csv"; my $file = shift; my @fn; my $sql; $fh = new IO::File; $dbh = DBI ->connect("dbi:Pg:dbname=$db;host=$host","olegk","4Q2073gl",{AutoCommit=>0,RaiseError=>1,ChopBlanks=>1}); $dbh->do("truncate table mis.\"geoip\""); $sth = $dbh->prepare("INSERT INTO mis.\"geoip\"(\"Begin_IP\", \"End_IP\", \"Begin_IP_Num\", \"End_IP_Num\", \"Country_Code\", \"Country_Name\") VALUES (?,?,?,?,?,?)"); open(FI,'<',"$file"); @strings=; foreach $line (@strings) { $line =~ s/^\"(.*)\"$/$1/; @fn = split('","',$line); # print join(" : ",@fn)."\n"; #$sql = "INSERT INTO mis.\"geoip\"(\"Begin_IP\", \"End_IP\", \"Begin_IP_Num\", \"End_IP_Num\", \"Country_Code\", # \"Country_Name\") VALUES ('$fn[0]','$fn[1]', $fn[2], $fn[3],'$fn[4]','$fn[5]')"; #print "$sql\n"; $sth->execute($fn[0],$fn[1],$fn[2],$fn[3],$fn[4],$fn[5]) ; } close(FI); $sth->finish; $dbh->commit; $dbh->disconnect;