]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Deprecate SQLite pool selection based on mode=memory
authorItachi-0xAI <285282994+Itachi-0xAI@users.noreply.github.com>
Thu, 13 Aug 2026 15:06:20 +0000 (11:06 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 13 Aug 2026 17:44:48 +0000 (13:44 -0400)
commitabd177230f2c6a8166e07c71010e8e27004b9740
tree300c2246201d4e31e149c87e653f61aeae986e2c
parentc98166ef40ac7f00d1cfa6e25317a769875a7e1e
Deprecate SQLite pool selection based on mode=memory

Deprecated the selection of a single-connection pool class, i.e.
SingletonThreadPool for pysqlite or StaticPool for aiosqlite, based
on the presence of the ``mode=memory`` query string argument in a
SQLite URL.  Pool selection for SQLite is intended to be based on the
database name alone, where only ``:memory:`` or an empty database
name indicate a memory database; interpreting the query string
additionally requires that assumptions be made regarding whether or
not the resulting database can be shared among multiple connections.
In a future release, such URLs will make use of QueuePool or
AsyncAdaptedQueuePool as would any other URL.  This notably includes
the shared cache form
``sqlite:///file:mydb?mode=memory&cache=shared&uri=true``, for which a
queue pool is in fact the appropriate class, as a shared cache
database supports multiple concurrent connections, whereas a
single-connection pool causes such connections to share one
transaction state.  Applications that rely upon the present behavior
should indicate the intended pool using the create_engine.poolclass
parameter.

Added a warning for query string arguments that are passed to a
SQLite URL without the ``uri=true`` argument also being present, and
which are not accepted by the ``sqlite3`` driver itself.  SQLite URI
arguments such as ``mode`` or ``cache`` take effect only when URI mode
is in use; without it they were previously discarded silently, so that
a URL such as ``sqlite:///file:mydb?mode=memory`` would connect to a
file on disk named ``file:mydb``.

Corrected the SQLite documentation regarding shared cache memory
databases, which incorrectly indicated that the named form
``sqlite:///file:mydb?mode=memory&cache=shared&uri=true`` makes use of
QueuePool; a single-connection pool is used for this form.
Documentation has also been added noting that a shared cache database
exists only for as long as at least one connection to it remains open,
so that ordinary pool operations such as Engine.dispose() or use of
create_engine.pool_recycle will discard its contents.

Fixes: #13433
Closes: #13465
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13465
Pull-request-sha: fc50a9837fd50334450ee6c9dd645db1b27b4dad

Change-Id: Iac1d334f92fd2ed49f6dafd324f24354d517a041
doc/build/changelog/unreleased_21/13433.rst [new file with mode: 0644]
doc/build/errors.rst
lib/sqlalchemy/dialects/sqlite/aiosqlite.py
lib/sqlalchemy/dialects/sqlite/pysqlite.py
lib/sqlalchemy/exc.py
test/dialect/sqlite/test_dialect.py
test/engine/test_parseconnect.py