mardi 16 mars 2021

How to give an SQLite3 in-memory database persistence efficiently

I very often use SQLite3 databases for quick and dirty internal tools geared toward non-technical level users. One tool is being used much more than expected and needs some optimization. It seems like moving the database to in-memory is the most straight forward way to do this; however, a key issue with this approach is the loss of persistence (IE: the application stops and the data in the database disappears).

While I would like to be able to catch the application exiting and trigger a backup of the active DB to disk, realistically I don't have the time to handle all the edge cases. I was wondering if there were other ways of backing up the in-memory SQLite3 database to handle unexpected stops to the application?

The simplest way would be to keep a copy of the database on disk and write to it when the in-memory database is written to, but I am not sure how well that performs and I also worry about the two databases becoming unsynchronized.




Aucun commentaire:

Enregistrer un commentaire