#!/usr/local/bin/perl use DBI; &MakeTable; &InsertValues; sub MakeTable() { use DBI; #print "enter username\n"; $dbh = DBI->connect("dbi:mysql:namesdb", 'some' , 'someother',{ Auto +Commit => 1, RaiseError => 1}) or die "connection error:$DBI::errstr\ +n"; $dbh-> do( "create table if not exists names ( #stuff );" ); $dbh-> disconnect; }#sub ends here; sub InsertValues() { $tablename="names"; $infile = '/path/names.dmp'; # $field= "\t|\t"; # field ending syntax from file; $lines="\t|\n";#lines ending syntax from file; $command = qq ~load data infile '$infile' ignore into table $tablen +ame FIELDS terminated by '$field' LINES terminated by '$lines';~; $dbh = DBI->connect("dbi:mysql:namesdb", 'some' , 'someother',{ Auto +Commit => 1, RaiseError => 1}) or die "connection error:$DBI::errstr\ +n"; $dbh->do($command); $dbh-> disconnect; }
Jun 14, 2008 at 04:22 UTC McDarren Added code tags, removed excessive whitespace
In reply to Re^2: DBI connect problems
by Anonymous Monk
in thread DBI connect problems
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |