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