Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: DBD::CSV::st execute failed:

by Tux (Canon)
on May 28, 2016 at 09:28 UTC ( [id://1164380]=note: print w/replies, xml ) Need Help??


in reply to DBD::CSV::st execute failed:

If you use f_ext => ".csv/r", you explicitly tell the driver that the extension is required. If you add the /r, you should not add .csv to the table name. The driver will still be able to open your file, but it is not quaranteed anymore which file it opens: newCsv, newCsv.csv, or newCsv.csv.csv.

Another issue is case sensitivity. On Windows newCsv will match against any casing. On Linux you might need to check if your file name matches.

$ cat newCsv.csv foo,bar,baz 1,2,3 $ perl -MDP -MDBI -e'my$s=DBI->connect("dbi:CSV:",undef,undef,{f_ext=> +".csv/r"})->prepare("select * from newCsv");$s->execute;DDumper$s->fe +tchrow_hashref' { bar => 2, baz => 3, foo => 1 } $ perl -MDP -MDBI -e'my$s=DBI->connect("dbi:CSV:",undef,undef,{f_ext=> +".csv/r"})->prepare("select * from newCsv.csv");$s->execute;DDumper$s +->fetchrow_hashref' { bar => 2, baz => 3, foo => 1 } $ perl -MDP -MDBI -e'my$s=DBI->connect("dbi:CSV:",undef,undef,{f_ext=> +".csv/r"})->prepare("select * from newcsv");$s->execute;DDumper$s->fe +tchrow_hashref' DBD::CSV::st execute failed: Execution ERROR: Cannot open /tmp/ne.csv: No such file or directory (2 +) at /pro/lib/perl5/site_perl/5.24.0/x86_64-linux-thread-multi-ld/DBI +/DBD/SqlEngine.pm line 1624. . [for Statement "select * from newcsv"] at -e line 1. DBD::CSV::st fetchrow_hashref failed: Attempt to fetch row without a p +receding execute () call or from a non-SELECT statement [for Statemen +t "select * from newcsv"] at -e line 1. undef

I see that the error message could use some improvement :)


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: DBD::CSV::st execute failed:
by Tux (Canon) on May 28, 2016 at 14:12 UTC

    The wrong error message actually proved to be a bug in DBI, which I now fixed and pushed.


    Enjoy, Have FUN! H.Merijn
Re^2: DBD::CSV::st execute failed:
by Sandy_Bio_Perl (Beadle) on May 28, 2016 at 10:44 UTC

    Thank you, Tux. I have removed the file extension .csv, and I note your comments on case sensitivity - all table headings etc are lower case and the csv file is correctly cased - if that is the right expression - as newCsv.csv.

    Sadly, I still get the same error messages. Still seeking divine guidance from the Monastery!!

      It might be handy to post a part of the file, perhaps a head -n 20 (that is to say, the first 20 lines) so that experimentation is easier.

      (and the actual filename)

        Hello again erix, here are the first 4 colums (sid, genotype, gender and tgroup, together with the first 19 rows of data. Thanks for helping me.

        sid genotype gender tgroup 1 c female 3 2 b male 3 3 c male 3 4 b male 1 5 c female 3 6 b male 1 7 a female 2 8 a male 3 9 d male 1 10 a female 2 11 d male 2 12 d female 2 13 d male 2 14 d female 1 15 d female 4 16 d female 2 17 d male 3 18 c male 1 19 a male 1

        Thank you erix. The headings of my spreadsheet, which is called newCsv.csv (that is the correct case sensitivity) are

        Headings of spreadsheet are: sid name genotype gender tgroup dnabl dnatw2 dnatw4 dnatw8 dnatw12 dnatw16 dnatw24 dnatw48 dnatw8-bl eagabscr eagabbl eagabtw12 eagabtw24 eagabtw48 altscr altbl alttw2 alttw4 alttw8 alttw12 alttw16 alttw24 alttw48 coretcellbl coretcelltw4 coretcelltw8 coretcelltw12 coretcelltw16 coretcelltw24 coretcelltw48 surfacetcellbl surfacetcelltw4 surfacetcelltw8 surfacetcelltw12 surfacetcelltw16 surfacetcelltw24 surfacetcelltw48 hla_a_1 hla_a_2 hla_b_1 hla_b_2 drb1*_1 drb1*_2 drb3*_1 drb3*_2 drb4*_1 drb4*_2 drb5*_1 drb5*_2 x_1 x_2

        Is that what you wanted?

Log In?
Username:
Password:

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

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

    No recent polls found