archipy-sqlite 5.22.0__tar.gz → 5.23.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/PKG-INFO +3 -2
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/archipy/adapters/sqlite/sqlalchemy/session_managers.py +29 -4
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/pyproject.toml +3 -2
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/.gitignore +0 -0
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/README.md +0 -0
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/archipy/adapters/sqlite/__init__.py +0 -0
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/archipy/adapters/sqlite/sqlalchemy/__init__.py +0 -0
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/archipy/adapters/sqlite/sqlalchemy/adapters.py +0 -0
- {archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/archipy/adapters/sqlite/sqlalchemy/session_manager_registry.py +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: archipy-sqlite
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.23.0
|
|
4
4
|
Summary: ArchiPy sqlite adapter.
|
|
5
5
|
Author-email: Hossein Nejati <hosseinnejati14@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
7
|
Requires-Python: <4,>=3.14
|
|
8
8
|
Requires-Dist: aiosqlite>=0.22.1
|
|
9
|
-
Requires-Dist: archipy==5.
|
|
9
|
+
Requires-Dist: archipy==5.23.0
|
|
10
|
+
Requires-Dist: sqlalchemy[asyncio]>=2.1.6
|
|
10
11
|
Description-Content-Type: text/markdown
|
|
11
12
|
|
|
12
13
|
# archipy-sqlite
|
|
@@ -19,6 +19,22 @@ _ASYNC_DRIVER = "sqlite+aiosqlite"
|
|
|
19
19
|
_SYNC_DRIVERS = frozenset({"sqlite", "sqlite+pysqlite"})
|
|
20
20
|
# Queue-pool-only arguments; SQLite in-memory engines use SingletonThreadPool/StaticPool, which reject them.
|
|
21
21
|
_QUEUE_POOL_ONLY_KWARGS = frozenset({"pool_size", "max_overflow", "pool_timeout", "pool_use_lifo"})
|
|
22
|
+
_MEMORY_DATABASE = ":memory:"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _uses_single_connection_pool(database: str | None) -> bool:
|
|
26
|
+
"""Return whether SQLAlchemy gives the SQLite database a single-connection pool.
|
|
27
|
+
|
|
28
|
+
SQLAlchemy 2.1 selects the pool class from the database name alone: an empty name or ``:memory:`` gets
|
|
29
|
+
SingletonThreadPool/StaticPool, any other name (including a ``mode=memory`` URI) gets QueuePool.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
database: The configured SQLite database path.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
bool: True for ``:memory:`` or an empty path.
|
|
36
|
+
"""
|
|
37
|
+
return not database or database == _MEMORY_DATABASE
|
|
22
38
|
|
|
23
39
|
|
|
24
40
|
def _is_in_memory(database: str | None) -> bool:
|
|
@@ -28,13 +44,19 @@ def _is_in_memory(database: str | None) -> bool:
|
|
|
28
44
|
database: The configured SQLite database path.
|
|
29
45
|
|
|
30
46
|
Returns:
|
|
31
|
-
bool: True for ``:memory:``, an empty path, or a ``
|
|
47
|
+
bool: True for ``:memory:``, an empty path, or a memory URI such as ``file::memory:?cache=shared`` or
|
|
48
|
+
``file:name?mode=memory&cache=shared``.
|
|
32
49
|
"""
|
|
33
|
-
|
|
50
|
+
if not database:
|
|
51
|
+
return True
|
|
52
|
+
return _MEMORY_DATABASE in database or "mode=memory" in database
|
|
34
53
|
|
|
35
54
|
|
|
36
55
|
def _sqlite_pool_kwargs(configs: SQLiteSQLAlchemyConfig, pool_kwargs: dict[str, Any]) -> dict[str, Any]:
|
|
37
|
-
"""Drop
|
|
56
|
+
"""Drop pool arguments that SQLite in-memory databases cannot use.
|
|
57
|
+
|
|
58
|
+
Recycling closes the connection, and closing the last connection to an in-memory database discards it, so
|
|
59
|
+
``pool_recycle`` is never passed for one. Single-connection pools also reject queue-pool arguments.
|
|
38
60
|
|
|
39
61
|
Args:
|
|
40
62
|
configs: SQLite configuration.
|
|
@@ -45,7 +67,10 @@ def _sqlite_pool_kwargs(configs: SQLiteSQLAlchemyConfig, pool_kwargs: dict[str,
|
|
|
45
67
|
"""
|
|
46
68
|
if not _is_in_memory(configs.DATABASE):
|
|
47
69
|
return pool_kwargs
|
|
48
|
-
|
|
70
|
+
dropped = {"pool_recycle"}
|
|
71
|
+
if _uses_single_connection_pool(configs.DATABASE):
|
|
72
|
+
dropped |= _QUEUE_POOL_ONLY_KWARGS
|
|
73
|
+
return {key: value for key, value in pool_kwargs.items() if key not in dropped}
|
|
49
74
|
|
|
50
75
|
|
|
51
76
|
class SQLiteSQLAlchemySessionManager(BaseSQLAlchemySessionManager[SQLiteSQLAlchemyConfig], metaclass=Singleton):
|
|
@@ -5,10 +5,11 @@ authors = [
|
|
|
5
5
|
{ name = "Hossein Nejati", email = "hosseinnejati14@gmail.com" },
|
|
6
6
|
]
|
|
7
7
|
readme = "README.md"
|
|
8
|
-
version = "5.
|
|
8
|
+
version = "5.23.0" # This version is set on publish flow!
|
|
9
9
|
requires-python = ">=3.14,<4"
|
|
10
10
|
dependencies = [
|
|
11
|
-
"archipy==5.
|
|
11
|
+
"archipy==5.23.0", # Pinned to core version on publish flow!
|
|
12
|
+
"sqlalchemy[asyncio]>=2.1.6",
|
|
12
13
|
"aiosqlite>=0.22.1",
|
|
13
14
|
]
|
|
14
15
|
license = "Apache-2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/archipy/adapters/sqlite/sqlalchemy/__init__.py
RENAMED
|
File without changes
|
{archipy_sqlite-5.22.0 → archipy_sqlite-5.23.0}/archipy/adapters/sqlite/sqlalchemy/adapters.py
RENAMED
|
File without changes
|
|
File without changes
|