Here is the code:Its working well on the windows.I am trying to run this on linux.
#!/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 |