in reply to Re^2: Inserting CSV Into DB w/o CSV Modules
in thread Inserting CSV Into DB w/o CSV Modules
while(my $line = <INFILE> ) { $csv->parse($line); my ( $state,$city,$location ) = $csv->fields(); # assumming these + are col1,col2,col3 $sth->execute($state,$city,$location) or die "Couldn't execute que +ry: $dbh->errstr"; }
This will be slow. It would be a lot faster to do:
my $sql =<<SQL; LOAD DATA LOCAL INFILE '$infile' INTO TABLE tbl_name FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' SQL $dbh->do($sql);
See LOAD DATA
|
---|