Ok, I finally need touse MYSQL in Perl for a project i am doing. I'm trying to work out how to do a MySQL dump (of all the tables) into a file. So far the code I have is;
$query = "BACKUP TABLE tbl_name[lsql_CatLinks, lsql_CatRelations, lsql_Category, lsql_Changes, lsql_ClickTrack, lsql_Editors, lsql_EmailMailings, lsql_EmailTemplates, lsql_Links, lsql_MailingIndex, lsql_MailingList, lsql_MailingListIndex, lsql_Reviews, lsql_Users, lsql_Verify] TO 'file.sql'";
$sth = $DBH->prepare($query);
$sth = $DBH->execute();
mysql_close($DBH);
However, when running this I get;
Can't locate object method "execute" via package "DBI::db" at /home/ace-host/public_html/small_dumps/getsql.cgi line 47.
For help, please send mail to the webmaster (admin), giving this error message and the time and date of the error.
Anyone see what I've done wrong? I only need to use SQL in Perl this once....so all I have really done is put bits of code together and hope it works (which it obviously doesnt ).
Thanks
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Code:
$DBH = DBI->connect("DBI:mysql:dump_database", "root", "", { RaiseError => 0, PrintError => 0, AutoCommit => 1 }); $query = "BACKUP TABLE tbl_name[lsql_CatLinks, lsql_CatRelations, lsql_Category, lsql_Changes, lsql_ClickTrack, lsql_Editors, lsql_EmailMailings, lsql_EmailTemplates, lsql_Links, lsql_MailingIndex, lsql_MailingList, lsql_MailingListIndex, lsql_Reviews, lsql_Users, lsql_Verify] TO 'file.sql'";
$sth = $DBH->prepare($query);
$sth = $DBH->execute();
mysql_close($DBH);
However, when running this I get;
Code:
Software error: Can't locate object method "execute" via package "DBI::db" at /home/ace-host/public_html/small_dumps/getsql.cgi line 47.
For help, please send mail to the webmaster (admin), giving this error message and the time and date of the error.
Anyone see what I've done wrong? I only need to use SQL in Perl this once....so all I have really done is put bits of code together and hope it works (which it obviously doesnt ).
Thanks
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!