Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: dump_mysql.pl - when you don't have mysqldump

by gmax (Abbot)
on Mar 07, 2002 at 09:27 UTC ( #149974=note: print w/ replies, xml ) Need Help??


in reply to dump_mysql.pl - when you don't have mysqldump

Nice job.
Some comments on the implementation:

  • If you don't want to prompt the user for username and password, it would be advisable to get them from a configuration file, instead of hardcoding them into the script. See this script for an example.
  • You don't need to get the table columns to create an INSERT statement. If you are inserting all the fields, your insert can be either "INSERT INTO tablename (col1 col2 col3) VALUES ('a','b','c')" or "INSERT INTO tablename VALUES ('a','b','c')". Of course this statement is helpful if the order of columns changes, but on a regular case it isn't needed.
The table structure can be created by adding this snippet:
# after printing the initial table comments print $dbh->selectall_arrayref("SHOW CREATE TABLE $table")->[0][1],"\n +";
Adding some parameters to let the user decide whether or not having this creation statement and maybe a DROP TABLE before it should be straightforward. Check Getopt::Long for some help.
 _  _ _  _  
(_|| | |(_|><
 _|   


Comment on Re: dump_mysql.pl - when you don't have mysqldump
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://149974]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-12-28 23:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls