Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Getting MySQL table info in perl script

Thread Tools

Getting MySQL table info in perl script

Posts: n/a
      11-03-2007 the column name, definitions (varchar(100) etc). The most
obvious way is to parse the output from describe table_name. Is there
an easier way? My goal is to create a generic INSERT sub, which takes
as args table_name and a hash reference, eg:

$table_name = "TheTable";
$hash(Int1) = 99;
$hash(Float2) = 1.54;
$hash(String7) = "Goodbye cruel world";

...where Float2, Int1, String7 are some but not all cols in mysql table
TheTable. The sub is invoked as follows:

DoInsert($table_name, \%hash);

DoInsert will generate and execute the INSERT statement, NULLing out
fields not in %hash, single quoting string fields, etc., maybe even
doing data tyep compatibility tests. I would be happy to learn that
some one has beaten me to it, and a procedure like DoInsert already

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
using mysql client to read a file to create a table in a database in a mysql server julian Ruby 8 04-06-2006 10:29 AM
pulling or getting perl script name inside script J M Perl Misc 2 11-06-2004 03:16 AM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM