in reply to Mysql and Perl Module
First of all: take the whole setting up out of the subroutine and into the main body of that script. That includes the DBI->connect stuff and preparing a statement handle.
This will make your script much faster because you don't keep reconnecting for every single row you want to insert. Same for the preparation of the statement handle. Prepare it once and pass the handle around (into the subroutine).
The next thing you should look up is how to use placeholders in your statement (questionmarks in the statement that are bound to values in the execute method.
Then there is the question of what it means if you have less than the full set of values in one row of your csv file. I guess those are "NULL" in your database, so you justneed to ensure that those values are "undef", which will insert them as NULLs.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Mysql and Perl Module
by endymion (Acolyte) on Jun 14, 2012 at 08:41 UTC | |
by Anonymous Monk on Jun 14, 2012 at 09:26 UTC | |
by tospo (Hermit) on Jun 14, 2012 at 09:29 UTC |