Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

SQLite Documentation

by cidaris (Friar)
on Jun 04, 2003 at 20:58 UTC ( #263146=perlquestion: print w/replies, xml ) Need Help??

cidaris has asked for the wisdom of the Perl Monks concerning the following question:

I've been searching long and hard for documentation on the DBI:SQLite module, but googling has only found me debian mirrors and changelogs. CPAN has minimal documentation, and there's no manpage ( unless I'm just daft ). I've looked through the actual .pm file a bit, but I won't claim to follow most of it.
I am hoping to find some supported methods, syntax examples, etc.
Here's my problem:

my $sql = "SELECT * FROM test"; my $sth = $dbh->prepare($sql) || die "Couldn't prepare $sql: $sth->err +str"; + + while ( @row = $sth->fetchrow_array ) { print "@row\n"; }

which is basically about as simple as it gets and the standard DBI way of doing it.

I'm getting this error:

dbih_setup_fbav: invalid number of fields: 0, NUM_OF_FIELDS attribute probably not set right at ./ line 12.
I'm kind of at a loss. Your help, or even just a pointer to a set of 'thorougher' docs, would be most appreciated.
Thanks! -- cidaris

2003-06-04 edit ybiC: s/pre/code/

Replies are listed 'Best First'.
Re: SQLite Documentation
by perrin (Chancellor) on Jun 04, 2003 at 21:37 UTC
    There is a man page, which is what you find when you perldoc DBD::SQLite or look it up on CPAN. It mostly says that it conforms to the DBD spec, so things you see in the DBI docs should work. For details on syntax to create tables, look at the SQLite docs.

    In your sample code, you never actually execute the statement handle.

      Wow, do I feel stupid. I completely missed that :) The following replicates his problem (along with the error message):

      my $sql = "SELECT * FROM foo"; my $sth = $dbh->prepare($sql) || die "Couldn't prepare $sql: $DBI::err +str"; while ( my @row = $sth->fetchrow_array ) { print "@row\n"; }

      This appears to be a bug in the error reporting.


      New address of my CGI Course.
      Silence is Evil (feel free to copy and distribute widely - note copyright text)

        Well, don't feel stupid, Ovid.
        After further examination and the hints of a few whispered messages (silent11) I realized that the "while" construct doesn't actually execute the prepared statement, only receives the output and continues to as long as it is produced.

        Adding an $sth->execute() directly before the loop solved the problem.

        I can't find an example in my code, but I feel fairly certain that I always just went straight to the "while" construct without an "execute()" with DBD::MySQL, but then again, I could be wrong.

        I usually am. ;)

Re: SQLite Documentation
by Ovid (Cardinal) on Jun 04, 2003 at 21:32 UTC

    My first suggestion would be to try a different version of DBD::SQLite. The actual error is from the DBI XS code and may stem from primary_key_info() in DBD::SQLite. You can either look in there or send a message to the DBI mailing list.

    If you know C (and XS), trying to find the actual problem and sending in a patch will be a Good Thing :)

    I'd also try bunding everything and trying to get it to run on a completely different box to find out if if the problem is specific to your box.


    New address of my CGI Course.
    Silence is Evil (feel free to copy and distribute widely - note copyright text)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://263146]
Approved by Ovid
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2023-06-04 14:08 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (22 votes). Check out past polls.