got a problem with perl dbi sqlite.
I have set up a database (and checked it with sqlite command line). Now i want to search in this database, which did not work.
So i tried to just do a 'SELECT *' this prints only the first element in the database, but not as it should everything in this table.
I think the error that causes the select * to fail is the same that prevents me from using "like %..%" stuff.
This is the relevant code, if the code is correct and the database table seems good what else could have caused the problems ?
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","") || die "Cannot connect: $DBI::errstr";
my $sth = $dbh->prepare('SELECT * FROM words');
$sth->execute;
my @result = $sth->fetchrow_array();
foreach( @result) {
print $_;
}
fetchrow_array() only fetches one row.
Try
while ( my @row = $sth->fetchrow_array ) {
print "@row\n";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With