From 22ed657827b487df9012def07271aed01bd4ae12 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 22 Dec 2021 08:34:15 -0500 Subject: use QueuePool for sqlite file databases The SQLite dialect now defaults to :class:`_pool.QueuePool` when a file based database is used. This is set along with setting the ``check_same_thread`` parameter to ``False``. It has been observed that the previous approach of defaulting to :class:`_pool.NullPool`, which does not hold onto database connections after they are released, did in fact have a measurable negative performance impact. As always, the pool class is always customizable via the :paramref:`_sa.create_engine.poolclass` parameter. Fixes: #7490 Change-Id: I5f6c259def0ef43d401c6163dc99f651e519148d --- test/dialect/test_sqlite.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'test/dialect') diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index 4fe419865..d7021a343 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -717,18 +717,22 @@ class DialectTest( assert e.pool.__class__ is pool.SingletonThreadPool e = create_engine("sqlite+pysqlite:///foo.db") - assert e.pool.__class__ is pool.NullPool + # changed as of 2.0 #7490 + assert e.pool.__class__ is pool.QueuePool @combinations( ( "sqlite:///foo.db", # file path is absolute - ([os.path.abspath("foo.db")], {}), + ([os.path.abspath("foo.db")], {"check_same_thread": False}), ), ( "sqlite:////abs/path/to/foo.db", - ([os.path.abspath("/abs/path/to/foo.db")], {}), + ( + [os.path.abspath("/abs/path/to/foo.db")], + {"check_same_thread": False}, + ), ), - ("sqlite://", ([":memory:"], {})), + ("sqlite://", ([":memory:"], {"check_same_thread": True})), ( "sqlite:///?check_same_thread=true", ([":memory:"], {"check_same_thread": True}), @@ -743,11 +747,17 @@ class DialectTest( ), ( "sqlite:///file:path/to/database?" "mode=ro&uri=true", - (["file:path/to/database?mode=ro"], {"uri": True}), + ( + ["file:path/to/database?mode=ro"], + {"uri": True, "check_same_thread": False}, + ), ), ( "sqlite:///file:path/to/database?uri=true", - (["file:path/to/database"], {"uri": True}), + ( + ["file:path/to/database"], + {"uri": True, "check_same_thread": False}, + ), ), ) def test_connect_args(self, url, expected): -- cgit v1.2.1