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")->,"\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.
_ _ _ _
(_|| | |(_|><
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||