Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: DBI DBD::SQLite unable to open Firefox cookies.sqlite database

by Corion (Patriarch)
on Nov 29, 2022 at 11:59 UTC ( [id://11148435]=note: print w/replies, xml ) Need Help??


in reply to DBI DBD::SQLite unable to open Firefox cookies.sqlite database

This seems to be a simple syntax error. The DSN string is too long:

qq(dbi:SQLite:dbname=$db,'','',{ ...

The qq() extends beyond the first comma, which is not what you want. You want:

qq(dbi:SQLite:dbname=$db),'','',{ ...

Usually, in such situations, I try to separate the steps:

my $dsn = "qq(dbi:SQLite:dbname=$db)"; my $user; my $password; my %dbi_options = ( RaiseError => 1, PrintError => 1, sqlite_open_flags => SQLITE_OPEN_READONLY, ); my $dbh = DBI->connect($dsn, $user, $password, \%dbi_options);

Replies are listed 'Best First'.
Re^2: DBI DBD::SQLite unable to open Firefox cookies.sqlite database
by Discipulus (Canon) on Nov 29, 2022 at 12:09 UTC
    Ah ah ah Corion what a shame from my part :)

    I modified the code but it fails anyway with empty var (both cookiesTEST.sqlite and cookies.sqlite tested) so it access the DB but still fails reading it

    use strict; use warnings; use Data::Dumper; use DBI; use DBD::SQLite; my $db = $ENV{AppData}.'\Mozilla\Firefox\Profiles\nwk2oixj.default-rel +ease\cookiesTEST.sqlite'; die "DB file not found!" unless -e $db; print "sqlite DBD version: $DBD::SQLite::sqlite_version\n"; my $dsn = qq(dbi:SQLite:dbname=$db); my $user; my $password; my %dbi_options = ( RaiseError => 1, PrintError => 1, sqlite_open_flags => 'SQLITE_OPEN_READONLY', ); my $dbh = DBI->connect($dsn, $user, $password, \%dbi_options); my $sth = $dbh->prepare(q(SELECT * FROM moz_cookies )); $sth->execute(); # PS added this and it works :) print Dumper $sth->fetchall_arrayref({}); __END__ sqlite DBD version: 3.39.4 $VAR1 = [];

    L*

    PS ..obviously executing the statement helps :) thanks 1nickt++

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found