in reply to DBD::SQLite select fails
Howdy bulrush! Could you be so kind and post complete, working code that demonstrates the problem? Yours not only doesn't compile (writeerr() is not included), it also doesn't do anything. Furthermore, it'd be nice if you could use proper <code> tags for your code, since that'll allow us to download code rather than having to copy and paste it.
Once we've got some code that demonstrates the issue you're experiencing, we'll be in a much better position to help you.
EDIT: to expand on the above, the following test script IS working for me:
#!/usr/bin/perl use strict; use warnings; use feature qw/say/; use DBD::SQLite; use Data::Dumper; our $dbfile = "test.db"; my $dbh = DBI->connect("dbi:SQLite:$dbfile", undef, undef, { AutoCommit => 1, RaiseError => 1 }); # create table, if necessary $dbh->do("CREATE TABLE IF NOT EXISTS data (skey TEXT PRIMARY KEY, sval +ue TEXT);"); # insert data $dbh->do("INSERT OR REPLACE INTO data (skey, svalue) VALUES ('Stuff', +'Ge 1:1-more \&stuff\& here ');"); # fetch data my $sth = $dbh->prepare("SELECT skey, svalue FROM data WHERE skey = 'S +tuff';"); $sth->execute(); my $results = $sth->fetchall_hashref("skey"); say Dumper $results;
This correctly prints:
$VAR1 = { 'Stuff' => { 'svalue' => 'Ge 1:1-more &stuff& here ', 'skey' => 'Stuff' } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBD::SQLite select fails
by bulrush (Scribe) on Aug 12, 2014 at 11:32 UTC | |
by AppleFritter (Vicar) on Aug 12, 2014 at 12:31 UTC |