The follow code fails to produce any data, and the tracing doesn't show any errors. What am I doing wrong?

#! perl -slw use strict; use DBI; use DBD::SQLite; my $dbh = DBI->connect( 'dbi:SQLite:dbname=test.fasta.db','','' ) or die DBI::errstr; $dbh->trace( 15 ); my $sth = $dbh->prepare( 'select * from fasta' ) or die DBI->errstr; $sth->trace( 15 ); while( 1 ) { my $data = $sth->fetchrow_arrayref or die $sth->errstr; print "$data : @{ $data }"; } __END__ c:\test>sqltest DBI::db=HASH(0x4054ca0) trace level set to 0x0/15 (DBI @ 0x0/0) in + DBI 1.609-ithread (pid 5936) -> prepare for DBD::SQLite::db (DBI::db=HASH(0x4054d48)~0x4054ca0 +'select * from fasta') thr#a8e58 New 'DBI::st' (for DBD::SQLite::st, parent=DBI::db=HASH(0x4054ca0) +, id=undef) dbih_setup_handle(DBI::st=HASH(0x4170708)=>DBI::st=HASH(0x4170678) +, DBD::SQLite::st, 3d70738, Null!) dbih_make_com(DBI::db=HASH(0x4054ca0), 3c5be08, DBD::SQLite::st, 2 +32, 0) thr#a8e58 dbih_setup_attrib(DBI::st=HASH(0x4170678), Err, DBI::db=HASH(0x405 +4ca0)) SCALAR(0x3d705e8) (already defined) dbih_setup_attrib(DBI::st=HASH(0x4170678), State, DBI::db=HASH(0x4 +054ca0)) SCALAR(0x3d706a8) (already defined) dbih_setup_attrib(DBI::st=HASH(0x4170678), Errstr, DBI::db=HASH(0x +4054ca0)) SCALAR(0x3d70648) (already defined) dbih_setup_attrib(DBI::st=HASH(0x4170678), TraceLevel, DBI::db=HAS +H(0x4054ca0)) 15 (already defined) dbih_setup_attrib(DBI::st=HASH(0x4170678), FetchHashKeyName, DBI:: +db=HASH(0x4054ca0)) 'NAME' (already defined) dbih_setup_attrib(DBI::st=HASH(0x4170678), HandleSetErr, DBI::db=H +ASH(0x4054ca0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x4170678), HandleError, DBI::db=HA +SH(0x4054ca0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x4170678), ReadOnly, DBI::db=HASH( +0x4054ca0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x4170678), Profile, DBI::db=HASH(0 +x4054ca0)) undef (not defined) sqlite trace: prepare statement: select * from fasta at dbdimp.c line +823 <- prepare= DBI::st=HASH(0x4170708) at C:\test\sqltest.pl line 11 -> trace in DBD::_::common for DBD::SQLite::st (DBI::st=HASH(0x417 +0708)~0x4170678 15) thr#a8e58 <- trace= 15 at C:\test\sqltest.pl line 14 -> fetchrow_arrayref for DBD::SQLite::st (DBI::st=HASH(0x4170708)~ +0x4170678) thr#a8e58 sqlite trace: numFields == 3, nrow == -1 at dbdimp.c line 1065 <- fetchrow_arrayref= undef row-1 at C:\test\sqltest.pl line 17 -> errstr in DBD::_::common for DBD::SQLite::st (DBI::st=HASH(0x41 +70708)~0x4170678) thr#a8e58 <- errstr= ( undef ) [1 items] at C:\test\sqltest.pl line 17 Use of uninitialized value in die at C:\test\sqltest.pl line 17. Died at C:\test\sqltest.pl line 17. -> DESTROY for DBD::SQLite::st (DBI::st=HASH(0x4170678)~INNER) thr +#a8e58 sqlite trace: destroy statement: select * from fasta at dbdimp.c line +1202 <- DESTROY= undef at C:\test\sqltest.pl line 17 via at C:\test\sq +ltest.pl line 17 -> DESTROY for DBD::SQLite::db (DBI::db=HASH(0x4054ca0)~INNER) thr +#a8e58 <- DESTROY= undef at C:\test\sqltest.pl line 17 via at C:\test\sq +ltest.pl line 17

But if I open the db with the sqlite3 executable, it runs the same query and produces output:

c:\test>sqlite3 test.fasta.db SQLite version 3.7.3 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> select * from fasta limit 10; >seq000001:|Some other descriptive text here|GAGCGAGCC >seq000002:|Some other descriptive text here|CTCGCGGGC >seq000003:|Some other descriptive text here|CATGTCCTG >seq000004:|Some other descriptive text here|GCCAAGTTT >seq000005:|Some other descriptive text here|CCTACGACT >seq000006:|Some other descriptive text here|GATGTCAGT >seq000007:|Some other descriptive text here|ACATCGCGA >seq000008:|Some other descriptive text here|ACGGCCATA >seq000009:|Some other descriptive text here|ATCGTCCCC >seq000010:|Some other descriptive text here|CCCGTGTCA sqlite> select count(*) from fasta; 1058202

Is there anything obviously wrong in my code; or visible in the trace?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to DBD::SQLite failing to return data? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.