in reply to Making DBI with SQLite3 truly read-only

sqlite_open_flags => "DBD::SQLite::OPEN_READONLY",
You're passing a string to sqlite_open_flags, while the documented way is an exported constant:
use DBD::SQLite::Constants qw/:file_open/; my $dbh = DBI->connect("dbi:SQLite:$dbfile", undef, undef, { sqlite_open_flags => SQLITE_OPEN_READONLY, });
Experiment shows that it's currently 1, but we shouldn't be relying on that value. Following the documented way, I see DBD::SQLite trying to open the file read-only:
$ strace -e trace=%file perl -MDBI -MDBD::SQLite::Constants=:file_open + -E' DBI->connect("dbi:SQLite:foo.sqlite", undef, undef, { sqlite_open_flags => SQLITE_OPEN_READONLY }); ' <...> openat(AT_FDCWD, "REDACTED/foo.sqlite", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) + <...>

Replies are listed 'Best First'.
Re^2: Making DBI with SQLite3 truly read-only
by ikegami (Patriarch) on Nov 04, 2025 at 20:48 UTC

    The following should also do the trick if you don't want to import constants you don't use:

    use DBD::SQLite::Constants qw( SQLITE_OPEN_READONLY );
Re^2: Making DBI with SQLite3 truly read-only
by mldvx4 (Hermit) on Nov 04, 2025 at 16:40 UTC

    Thanks. All set. Somehow I missed the use DBD::SQLite::Constants qw/:file_open/; part of the documentation, that led to a series of errors. With that in place, I can now use the constant as I am supposed to and the database is indeed read only at that point!