SQLite Forum

sqlite opens a database file in R/W mode, even if the file is read-only
Login
This behavior change is on purpose, in reaction to [threads like this one][1].

It's a *good thing*. SQLite can't know what SQL statements or queries you will execute, so why should a read-only attribute on the DB file — or its journal, or its parent directory, or its whole filesystem — be an impediment to merely *opening* the DB? If the subsequent query is `SELECT COUNT(*) FROM foo`, we don't need write access to the DB at all! As pointed out in the linked thread, WAL mode still allows proper locking in this case; there is not ACID failure simply because one client has the DB opened read-only.

I expect there would be more people upset if the new behavior was reverted than there are people caught out by the new behavior.

Indeed, this feels like an XKCD Workflow problem to me: <https://xkcd.com/1172/>

[1]: /forumpost/ecec426355