nh2
nh2

Reputation: 25695

Opening a WAL sqlite DB read-only

I have a WAL DB on read-only media (that is, db.sqlite, db.sqlite-wal and db.sqlite-shm).

I know I can't open it readonly just like that because according to the docs, "even ordinary reads in WAL mode require recovery-like operations".

But can I tell sqlite to open it into memory, and doing the recovery from read-only WAL files in memory?

So that I would end up with a recovered and fully operational in-memory DB that has the same contents as the files on disks.

Upvotes: 2

Views: 2087

Answers (1)

CL.
CL.

Reputation: 180210

Copy the files to a RAM disk (wherever a tmpfs is mounted).

This could have been avoided by following the recommendation that

SQLite databases should always be converted to PRAGMA journal_mode=DELETE prior to being transferred to read-only media.

Upvotes: 3

Related Questions