SQLite Forum

In-memory database from sqlite file
Thanks so much for all your answers!

> I believe you'd be looking to use the [deserialize](https://www.sqlite.org/c3ref/deserialize.html) interface.

This looks exactly like what we need! The [Go bindings that we use](https://github.com/mattn/go-sqlite3) don't support this functionality yet, but it would be a worthy addition to discuss with the author.

> Bear in mind though that the other process could be in the middle of writing to the file at any moment, and thus your memory copy of the file contents could be completely inconsistent and broken. There's pretty much nothing you can do to prevent that when you're skirting around the mechanisms put in place to ensure consistency.

Isn't consistency one of the main advantages of a SQL database? How can a database get corrupted by copying a DB file to memory (or to a temporary file, like in our current solution) while in the middle of a transaction? What I mean is, this shouldn't be any different from a power outage that happens while the DB is being written to, and to my understanding SQLite guarantees consistency in this scenario.

Note: I am not a DB expert, so my understanding of the similarities between these two scenarios could be just completely flawed. :)