diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-12-22 08:34:15 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-02-10 11:09:22 -0500 |
commit | 22ed657827b487df9012def07271aed01bd4ae12 (patch) | |
tree | f1c0693953df077c00840321d3dbf563351d2698 /test/dialect/test_sqlite.py | |
parent | 449389a45f358300ba95f7d03c7b94b64703e31a (diff) | |
download | sqlalchemy-22ed657827b487df9012def07271aed01bd4ae12.tar.gz |
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
Diffstat (limited to 'test/dialect/test_sqlite.py')
-rw-r--r-- | test/dialect/test_sqlite.py | 22 |
1 files changed, 16 insertions, 6 deletions
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): |