No Such Table error from SQLite memory DB via DataMapper No Such Table error from SQLite memory DB via DataMapper sqlite sqlite

No Such Table error from SQLite memory DB via DataMapper


The problem is, I suspect, due to the thread pooling which DataMapper (or more accurately, DataObjects, the database driver DataMapper uses) does automatically. The database connection isn't shared between threads. This is fine (and beneficial, even) for something like postgresql or mysql or even sqlite3 as a 'file-backed' database. In the case of sqlite3's in memory store, the connection is the database. So additional threads will fail for that reason. Also, after a period of inactivity (~1 min?), the thread will get scavenged and the database will go away too.

If it is this, I'm not sure there's an easy work around. You might be able to modify do_sqlite3 to avoid this. Another alternative that should be basically as fast, is to use a file-backed sqlite3 DB on a ramdrive.


I copy my comment as answer by suggestion of @Lukas_Skywalker

Too late I know but maybe it can help someone. You can use memory SQLite shared cache using the special filename file::memory:?cache=shared. This allows separate database connections to share the same in-memory database. sqlite.org/inmemorydb.html