archipy-postgres 5.23.0__tar.gz → 5.25.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_postgres-5.23.0 → archipy_postgres-5.25.0}/PKG-INFO +2 -2
- {archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/archipy/adapters/postgres/sqlalchemy/session_managers.py +46 -4
- {archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/pyproject.toml +2 -2
- {archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/.gitignore +0 -0
- {archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/README.md +0 -0
- {archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/archipy/adapters/postgres/__init__.py +0 -0
- {archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/archipy/adapters/postgres/sqlalchemy/__init__.py +0 -0
- {archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/archipy/adapters/postgres/sqlalchemy/adapters.py +0 -0
- {archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/archipy/adapters/postgres/sqlalchemy/session_manager_registry.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: archipy-postgres
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.25.0
|
|
4
4
|
Summary: ArchiPy postgres 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
|
-
Requires-Dist: archipy==5.
|
|
8
|
+
Requires-Dist: archipy==5.25.0
|
|
9
9
|
Requires-Dist: psycopg[binary]>=3.3.6
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
|
|
@@ -15,6 +15,48 @@ from archipy.helpers.metaclasses.singleton import Singleton
|
|
|
15
15
|
from archipy.models.errors import DatabaseConnectionError
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
def _build_connect_args(configs: PostgresSQLAlchemyConfig) -> dict[str, Any]:
|
|
19
|
+
"""Build the psycopg connection arguments from the configuration.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
configs: PostgreSQL configuration.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
dict[str, Any]: Only the options that are configured (libpq defaults apply to the rest).
|
|
26
|
+
"""
|
|
27
|
+
candidates = {
|
|
28
|
+
"connect_timeout": configs.CONNECT_TIMEOUT,
|
|
29
|
+
"sslmode": configs.SSL_MODE,
|
|
30
|
+
"sslrootcert": configs.SSL_ROOT_CERT,
|
|
31
|
+
"sslcert": configs.SSL_CERT,
|
|
32
|
+
"sslkey": configs.SSL_KEY,
|
|
33
|
+
"application_name": configs.APPLICATION_NAME,
|
|
34
|
+
"options": _build_server_options(configs),
|
|
35
|
+
"prepare_threshold": configs.PREPARE_THRESHOLD,
|
|
36
|
+
}
|
|
37
|
+
connect_args: dict[str, Any] = {name: value for name, value in candidates.items() if value is not None}
|
|
38
|
+
if configs.DISABLE_PREPARED_STATEMENTS:
|
|
39
|
+
connect_args["prepare_threshold"] = None # psycopg: None never prepares
|
|
40
|
+
return connect_args
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _build_server_options(configs: PostgresSQLAlchemyConfig) -> str | None:
|
|
44
|
+
"""Build the libpq ``options`` string that sets the session timeouts.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
configs: PostgreSQL configuration.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
str | None: e.g. ``-c statement_timeout=5000 -c lock_timeout=1000``, or None when neither is set.
|
|
51
|
+
"""
|
|
52
|
+
settings = {
|
|
53
|
+
"statement_timeout": configs.STATEMENT_TIMEOUT_MS,
|
|
54
|
+
"lock_timeout": configs.LOCK_TIMEOUT_MS,
|
|
55
|
+
}
|
|
56
|
+
options = [f"-c {name}={value}" for name, value in settings.items() if value is not None]
|
|
57
|
+
return " ".join(options) or None
|
|
58
|
+
|
|
59
|
+
|
|
18
60
|
class PostgresSQlAlchemySessionManager(BaseSQLAlchemySessionManager[PostgresSQLAlchemyConfig], metaclass=Singleton):
|
|
19
61
|
"""Synchronous SQLAlchemy session manager for PostgreSQL.
|
|
20
62
|
|
|
@@ -64,9 +106,9 @@ class PostgresSQlAlchemySessionManager(BaseSQLAlchemySessionManager[PostgresSQLA
|
|
|
64
106
|
"""Return the psycopg connection arguments.
|
|
65
107
|
|
|
66
108
|
Returns:
|
|
67
|
-
dict[str, Any]:
|
|
109
|
+
dict[str, Any]: The configured connect timeout, TLS, application name, session timeout and prepare options.
|
|
68
110
|
"""
|
|
69
|
-
return
|
|
111
|
+
return _build_connect_args(self._configs)
|
|
70
112
|
|
|
71
113
|
@override
|
|
72
114
|
def _create_url(self, configs: PostgresSQLAlchemyConfig) -> URL:
|
|
@@ -148,9 +190,9 @@ class AsyncPostgresSQlAlchemySessionManager(
|
|
|
148
190
|
"""Return the psycopg connection arguments.
|
|
149
191
|
|
|
150
192
|
Returns:
|
|
151
|
-
dict[str, Any]:
|
|
193
|
+
dict[str, Any]: The configured connect timeout, TLS, application name, session timeout and prepare options.
|
|
152
194
|
"""
|
|
153
|
-
return
|
|
195
|
+
return _build_connect_args(self._configs)
|
|
154
196
|
|
|
155
197
|
@override
|
|
156
198
|
def _create_url(self, configs: PostgresSQLAlchemyConfig) -> URL:
|
|
@@ -5,10 +5,10 @@ authors = [
|
|
|
5
5
|
{ name = "Hossein Nejati", email = "hosseinnejati14@gmail.com" },
|
|
6
6
|
]
|
|
7
7
|
readme = "README.md"
|
|
8
|
-
version = "5.
|
|
8
|
+
version = "5.25.0" # This version is set on publish flow!
|
|
9
9
|
requires-python = ">=3.14,<4"
|
|
10
10
|
dependencies = [
|
|
11
|
-
"archipy==5.
|
|
11
|
+
"archipy==5.25.0", # Pinned to core version on publish flow!
|
|
12
12
|
"psycopg[binary]>=3.3.6",
|
|
13
13
|
]
|
|
14
14
|
license = "Apache-2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/archipy/adapters/postgres/sqlalchemy/__init__.py
RENAMED
|
File without changes
|
{archipy_postgres-5.23.0 → archipy_postgres-5.25.0}/archipy/adapters/postgres/sqlalchemy/adapters.py
RENAMED
|
File without changes
|
|
File without changes
|