Fix bug where NullPool is used for in-memory SQLite created using
filename uri instead of ":memory:".
Checks for in-memory SQLite database created using filename uri like
"file:foo.db?mode=memory&uri=true" in addition to in-memory SQLite
database created using the standard ":memory:".
Fixes: #6379
@classmethod
def _is_url_file_db(cls, url):
- if url.database and url.database != ":memory:":
+ if (url.database and url.database != ":memory:") and (
+ url.query.get("mode", None) != "memory"
+ ):
return True
else:
return False
e = create_engine("sqlite+pysqlite:///:memory:")
assert e.pool.__class__ is pool.SingletonThreadPool
+ e = create_engine(
+ "sqlite+pysqlite:///file:foo.db?mode=memory&uri=true"
+ )
+ assert e.pool.__class__ is pool.SingletonThreadPool
+
e = create_engine("sqlite+pysqlite:///foo.db")
assert e.pool.__class__ is pool.NullPool