in reply to Re^2: Import dump file into mysql DB using DBI
in thread Import dump file into mysql DB using DBI
I still prefer to use mysql command line for this task. If you think you have to use a perl sript, then I assume you have remote access to the DB server, in which case you can also use the mysql client from your host.
SQL files (.sql) are meant to be executed in batch mode, each statement is terminated with a semicolon (";"). With DBI, you execute query one statement at a time and semicolons are disliked :-)
Finally, if you still need a perl script to automate DB updating (still assuming you the remote access), this might help (sorry, I don't bother to test it).
Also, you may want to consider about DB backup and/or hotcopy, as both facilities are provided by mysql, AFAIK.
my $sql_file = '/path/to/sql/file.sql';
exit 0 # silently
unless -r $sql_file;
my $user = 'user';
my $pass = 'pass';
my $db = 'somedb';
system "mysql -u$user -p$pass $somedb < $sql_file"
and die "can't update $db\n";
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!