SQLite Forum

How to replace SQLite DB in WAL-mode ?
Login

How to replace SQLite DB in WAL-mode ?

(1) By Коренберг Марк (socketpair) on 2021-01-14 17:54:00 [source]

I have a DB in WAL mode. I need to replace the whole database while there are precesses still connected.  These processes are supposed to re-connect by external event.

I can not do it logically (using SQL) because it would be very slow. If it were single file, It would be easy. But unfortunatelly there is a WAL. I afraid of race-conditions when DB file is replaced, but WAL from OLD db is still there.

(2) By Larry Brasfield (LarryBrasfield) on 2021-01-14 19:17:29 in reply to 1 [link] [source]

The backup API would circumvent your race concern. Of course, due to the same uncertainties leading to that concern, there would still be a question as to what version of the database would be replaced by the created backup.