this is actually bothers me already for a few days. I have a sqlite database (arround 300 megabytes) that I need to reed from really fast. That is the reason why I've decided to use in memory mode in sqlite with backup function. Here is my problem based in this sqlite doc. Here is mu struggle. When I use URI filename ":memory:" and then backup.
Everythink si fine I even see in htop that process now has + 300 bytes in memory. So every think is golden.
But because I need to access this database from multiple threads and there for I cannot simply share single pointer to db connection. I want to assign name to my memory database and set it's cache as shared. But when I do that like so:
sqlite3_open("file:memdb1?mode=memory&cache=shared", &db);
Which is URI file name copied from the documentation. After backup database no longer adds 300MB into ma memory process and file with name "file:memdb1?mode=memory&cache=shared" is created on my disk I've also tried "file::memory:?cache=shared" but with same results.
I'm on linux Fedora 31 with sqlite 3.30.0
Any ideas, suggestions are hugely welcomed.
Thank you all
The problem is that you are using URI filename which is disabled by default for backwards compatibility. You need to enable URI filename, see doc for your options.
One way cloud be simply:
sqlite3_open_v2("file:memdb1?mode=memory&cache=shared", &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI, null);