3 ms·
Yes, it works very well. If you have only one thread/process, use it as is; if you need multiple readers and one writer (who do not block each other), use WAL
by beagle3 7y ago
Yes, it works very well.
If you have only one thread/process, use it as is; if you need multiple readers and one writer (who do not block each other), use WAL mode; if you need simultaneous multiple readers and writers, use Postgres.
If you are using SQLite, be aware that the “copy the file to move it to a different system” comes with a caveat - a regular Unix “cp” may get the file in an inconsistent state if it was modified while copying, or in the middle of a transaction.
Iirc “rsync” if used to copy, will verify that the file was not modified while copying and restart the copy if it did (a number of times and then error out). But that’s still not enough - you may need to also copy the shm file (in wal mode) and the journal file - and you need to do that atomically. Which is harder still.
The right way to copy an SQLite file from place to place us:
Any way you like, if it was properly committed and closed last time it was used, and is not currently open by any other process;
Or creating a backup (e.g. with the sqlite3 command), which will be a nonblocking operation if in WAL more - and then you can ship the backup whichever way you want.