Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Error with DBD::CSV

by Tux (Canon)
on Aug 11, 2010 at 06:44 UTC ( [id://854227]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 04:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found