dimanche 8 février 2015

readonly open an existing **sqlite database file** from memory

I have sqlite database files in memory (downloaded from network). How can I open the database for read without dump the file to disk (ramdisk is not an option). I known sqlite supports :memory: to create an empty in-memory db but it is not for an existing db. The sqlite usually comes with three files: xxx.sqlitedb, xxx.sqlitedb-shm and xxx.sqlitedb-wal. I have all of them loaded in memory.


I found an related post How do I open an in-memory database file into sqlite3 But the answer (by @ChristopheD) seems not solved my task, or I just did not understand the trick. it is still based on some "backup.db" on the disk, isn't it?


The code is on Windows platform and Mac OSX. And I hope this can be done by just using sqlite C API. Thank you for reading my question :).


So basically, I need to implement such a function, for readonly access of the db:



sqlite3* open_sqlite_inmemory(
void* sqite_db, size_t sqite_db_size,
void* sqite_db_shm, size_t sqite_db_shm_size,
void* sqite_db_wal, size_t sqite_db_wal_size
);

Aucun commentaire:

Enregistrer un commentaire