SQLite Forum

In-memory database from sqlite file
Hello everybody,

Is it possible to read an sqlite file into a memory buffer, and then use that memory buffer as the database to connect to?

Context: I have a program using the SQLite3 library, which must read from time to time a table from an SQLite database. However, that database is usually locked in exclusive mode by another process (which I don't have control over), so that reading the DB file directly is impossible. A solution I have found is to just copy the file to a temporary file and then open that from SQLite - however, the overhead for this is very high (I've measured 25ms per access, versus 0.5ms if I just access the database directly without making a copy first). So a good solution would be to read the database in-memory (without making an actual copy), and then connect to that in-memory copy from SQLite. However, looking at the docs I could only see how I can create a new in-memory database, which is not my use case.

Thanks in advance!