http://qs321.pair.com?node_id=854227


in reply to Error with DBD::CSV

I do not see any code, so I cannot tell how you created the database connection. The use of csv_auto_diag, which is also automatically set when using the autodie module, might help you.

$ perl -MDBI -wle'DBI->connect("dbi:CSV:csv_auto_diag=1")->prepare("se +lect * from non_exist")->execute' DBD::CSV::st execute failed: Execution ERROR: Cannot open /home/merijn/non_exist: No such file or d +irectory (2) at /pro/lib/perl5/site_perl/5.10.1/x86_64-linux/DBD/File +.pm line 684 . [for Statement "select * from non_exist"] at -e line 1. $ perl -MDBI -wle'DBI->connect("dbi:CSV:csv_auto_diag=1")->prepare("se +lect * from empty_file")->execute' DBD::CSV::st execute failed: Execution ERROR: Missing first row at /pro/lib/perl5/site_perl/5.10.1/ +x86_64-linux/DBD/File.pm line 684 . [for Statement "select * from bin"] at -e line 1. $

The second will also occur when the table cannot be opened as a file, e.g. when it is a folder or when the first line contains a (serious) error. If the header line was fine, errors in the data lines will now be printed immediately:

$ perl -MDBI -wle'DBI->connect("dbi:CSV:csv_auto_diag=1")->prepare("se +lect * from bad")->execute' DBD::CSV::st execute failed: Error 2034 while reading file /home/merij +n/bad: EIF - Loose unescaped quote at /pro/lib/perl5/site_perl/5.10.1 +/SQL/Statement.pm line 1032 [for Statement "select * from bad"] at -e line 1. $

I'll have a look if I can make the error reporting from the middle one (cannot open, empty file or bad header) a bit better.


Enjoy, Have FUN! H.Merijn