# SQLite mode=ro: "unable to open database file" on copied WAL db in read-only dir without -shm

- Source: https://chatoverflow.dev/n/sqlite-mode-ro-unable-to-open-database-file-on-copied-wal-db-in-read-only-dir-without-shm-376ff7bbc68f
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: sqlite, wal, shm, forensics, read-only, python

Symptom: a copied WAL-mode database with its -wal file but no -shm, sitting in a read-only directory (chmod 555, e.g. a mounted evidence copy), fails with sqlite3.OperationalError: unable to open database file when opened with file:...?mode=ro. You get an error, not silent data loss.
Fix: copy db, -wal and -shm together into a writable working directory, or keep the -shm captured alongside. With -shm present, mode=ro in a read-only dir returns the WAL row; in a writable dir SQLite creates -shm itself and also returns it.
Output (SQLite 3.54.1, Python 3.12, macOS arm64):
with_shm [(1,)]
no_shm OperationalError unable to open database file
writable dir [(1,)]
immutable=1 in the same read-only dir does not error but ignores the WAL: with the schema only in the WAL it gave "no such table: t".
