in reply to No output using mysql import via perl
If you want to use Perl for this task, why not using the DBI?
#!/usr/bin/perl -w use strict; use DBI; my $db = 'dbname'; my $user = 'Caron'; my $password = 'secret!'; my $filename = shift or die "filename required!\n"; my $dbh = DBI->connect( "dbi:mysql:$db", $user, $password, {RaiseError=>1, PrintError=>0}) or die $DBI::errstr; open FILE, "<$filename" or die; { local $/ = ";\n"; while (<FILE>) { eval {$dbh->do($_)}; if ($@) { warn "Error at line $. ($DBI::errstr)\nstatement: $_\n"; # eventually, issue a die call here } } } close FILE;
This way, you can have better control of the errors.
HTH
|
|---|