SQLite weird state managing / caching
I am working on .NET API and I have some problems with handling/saving sqlite state. Before I post all of my code, I am using EF and handling dbcontext lifecycle with DI.
What is the process where the problems occur:
- Start API and send one POST requet to enter something in DB (when the API is starter, sqlite created WAL and SHM files)
- The entered data is visible on API website and always in DB Browser for Sqlite
- Stop API
- Data still visible in DB Browser. I can also close the browser and open it again, and the data is still there
- When I start the API again, the data dissapears. Its not visible in DB Browser, as well as in API website.
*Closing DB browser clears .WAL and .SHM files, stopping API doesnt
Any idea where the problem might be? Which part of the workflow?
3 Replies
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
oh wait
:harold:
thought i changed path at some point...looks like not anymore
and it actually might only be this
okay yeah, this was one part of the problem.. But I should still fix the part where stopping is not deleting/mergin cache files into original database file
*When opening an SQLite database, it creates some kind of "cache" files (.WAL and .SHM). Any change of data is written in those files, which are later on (on connection close or after specific number of new data) merged into original .db file
So I assume I am missing something when closing the connection.. but idk what, since I am not manually handling the connection