Closed Azratosh closed 2 years ago
I recommend using the first suggested approach: Keep a single connection active when a :memory: database is used This can be done by making a singleton that is used to get the database connection in the DatabaseManager instead of using a new connection each time.
@PKlempe is that fine for you?
Description
When setting the
DB_FILE_PATH
key in the.env
file to":memory:"
or:memory:
, ansqlite3.OperationalError
is raised on every query:Steps To Reproduce
DB_FILE_PATH
to:memory:
Cause
From the sqlite documentation:
:arrow_right: The in-memory database is deleted right after
DatabaseConnector
is instantiated (or theDatabaseManager
context manager is used).Proposed Solutions
:memory:
database is used?mode=memory&cache=shared
to the database's URI filename and use a connection pool. The database is deleted when the last connection closes, so at least one connection must always be open..env.example
, telling the developer to just use a separate persistent database for testing and debugging :brain::boom: