Re: MySql +DBI problem
- From: uttamhoode@xxxxxxxxx
- Date: 18 Aug 2006 03:52:26 -0700
ok ok :) sorry for not posting the code
no of lines inserted varies on each execution
#===============================
#!/usr/bin/perl
use Socket;
use DBI;
use CGI qw/:standard/;
$query=new CGI;
print $query->header;
# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=database
name;host=hostname",
"username", "password",
{'RaiseError' => 1})|| print "ERROR
CONNECTING";
open(FREADER,"csvfile.csv") or print "ERROR OPENING FILE \n";
if(!($error))
{
my $ln;
my $separator=$/;
undef $/;
$buff=<FREADER>;
$/=$separator;
undef $ln;
close FREADER;
}
my $ln;
my $i=1;
foreach $ln (split("\n",$buff))
{
$buff=~/REG EXP FOR SPLITTING EACH LINE/g;
my $qry="INSERT INTO IP(A,B, C, D, E, F, G, H )
VALUES('$i','$1','$2','$8','$9','$14','$17',".$dbh->quote($20).")";
$dbh->do($qry);
$i++;
}
print $i;
my $errstr=$dbh->errstr;
print $errstr;
$sth->finish();
# Disconnect from the database.
$dbh->disconnect();
close(MAILREADER);
usenet@xxxxxxxxxxxxxxx wrote:
uttamhoode@xxxxxxxxx wrote:
when i execute the script only aroud 31000 to 37000(varies each time)
lines are inserted....I am using a remote mysql server
You have an error on line 42.
And you're not checking your SQL return messages on lines 92, 111, and
141 (hint, hint).
--
David Filmer (http://DavidFilmer.com)
.
- Follow-Ups:
- Re: MySql +DBI problem
- From: Paul Lalli
- Re: MySql +DBI problem
- From: A. Sinan Unur
- Re: MySql +DBI problem
- References:
- MySql +DBI problem
- From: uttamhoode
- Re: MySql +DBI problem
- From: usenet
- MySql +DBI problem
- Prev by Date: Re: MySql +DBI problem
- Next by Date: Re: HOW to rename a NPH script ?
- Previous by thread: Re: MySql +DBI problem
- Next by thread: Re: MySql +DBI problem
- Index(es):
Relevant Pages
|