The open manpage of SQLite also shows the ?immutable parameter when using the uri= form of connecting to a DB. With that, I am able to read the Firefox cookies from a live SQLite database while Firefox is running.
use strict;
use warnings;
use Data::Dumper;
use DBI;
use DBD::SQLite;
my $mozilla_path = "$ENV{AppData}\\Mozilla\\Firefox\\Profiles";
opendir my $dh, $mozilla_path
or die "Couldn't read Mozilla profiles directory $mozilla_path: $!
+";
my ($profile) = grep { /\.default/ } readdir $dh;
my $file = "$mozilla_path/$profile/cookies.sqlite";
$file =~ s!\\!/!g;
die "DB file '$file' not found!" unless -e $file;
print "sqlite DBD version: $DBD::SQLite::sqlite_version\n";
my $dsn = "dbi:SQLite:uri=file:///$file?immutable=1";
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;
print Dumper $sth->fetchall_arrayref({});
The URI needs to be different between Windows and Unixish path specifications, but the SQLite documentation has examples for all of them.