datus-postgresql 0.1.12__tar.gz → 0.1.13__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.
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/PKG-INFO +3 -3
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/datus_postgresql/connector.py +11 -1
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/pyproject.toml +3 -3
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/test_timeouts.py +13 -1
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/unit/test_timeouts.py +32 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/.gitignore +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/README.md +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/datus_postgresql/__init__.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/datus_postgresql/config.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/datus_postgresql/handlers.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/datus_postgresql/testing.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/datus_postgresql/timeouts.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/datus_postgresql/tpch_data.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/docker-compose.tls.yml +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/docker-compose.yml +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/scripts/init_tpch_data.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/__init__.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/conftest.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/__init__.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/conftest.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/test_aurora_cloud.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/test_contract.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/test_integration.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/test_metadata_retrieval.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/test_tls.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/test_tpch.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/unit/__init__.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/unit/test_aurora.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/unit/test_config.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/unit/test_connector_unit.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/unit/test_migration_mixin.py +0 -0
- {datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/unit/test_scoped_ddl.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datus-postgresql
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.13
|
|
4
4
|
Summary: PostgreSQL database adapter for Datus
|
|
5
5
|
Project-URL: Homepage, https://github.com/Datus-ai/datus-db-adapters
|
|
6
6
|
Project-URL: Repository, https://github.com/Datus-ai/datus-db-adapters
|
|
@@ -14,8 +14,8 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Requires-Python: >=3.12
|
|
17
|
-
Requires-Dist: datus-db-core>=0.1.
|
|
18
|
-
Requires-Dist: datus-sqlalchemy>=0.1.
|
|
17
|
+
Requires-Dist: datus-db-core>=0.1.12
|
|
18
|
+
Requires-Dist: datus-sqlalchemy>=0.1.14
|
|
19
19
|
Requires-Dist: psycopg2-binary>=2.9.11
|
|
20
20
|
Requires-Dist: pydantic>=2.0.0
|
|
21
21
|
Requires-Dist: sqlglot>=30.0.0
|
|
@@ -9,7 +9,7 @@ from urllib.parse import quote_plus
|
|
|
9
9
|
|
|
10
10
|
from pydantic import BaseModel, Field
|
|
11
11
|
from sqlalchemy import text
|
|
12
|
-
from sqlalchemy.engine import URL, Engine
|
|
12
|
+
from sqlalchemy.engine import URL, Connection, Engine
|
|
13
13
|
from sqlglot.dialects.postgres import Postgres
|
|
14
14
|
from sqlglot.tokens import TokenType
|
|
15
15
|
|
|
@@ -109,6 +109,16 @@ class PostgreSQLConnector(SQLAlchemyConnector, MigrationTargetMixin):
|
|
|
109
109
|
}
|
|
110
110
|
configure_database_connection(self, config, connect_args, dialect="postgresql")
|
|
111
111
|
|
|
112
|
+
@property
|
|
113
|
+
def supports_query_timeout_override(self) -> bool:
|
|
114
|
+
return self.dialect in {"postgresql", "greenplum"} and not self.config.aurora
|
|
115
|
+
|
|
116
|
+
def _query_timeout_scope(self, conn: Connection, seconds: int):
|
|
117
|
+
# The SELECT shares this transaction. Checkout cleanup rolls it back,
|
|
118
|
+
# releasing the local setting without a second server-variable change.
|
|
119
|
+
conn.exec_driver_sql(f"SET LOCAL statement_timeout = {seconds * 1000}").close()
|
|
120
|
+
return nullcontext()
|
|
121
|
+
|
|
112
122
|
def _create_engine(self, connection_string: str | URL, **options: Any) -> Engine:
|
|
113
123
|
from .timeouts import configure_timeouts
|
|
114
124
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "datus-postgresql"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.13"
|
|
4
4
|
description = "PostgreSQL database adapter for Datus"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -18,8 +18,8 @@ classifiers = [
|
|
|
18
18
|
]
|
|
19
19
|
|
|
20
20
|
dependencies = [
|
|
21
|
-
"datus-db-core>=0.1.
|
|
22
|
-
"datus-sqlalchemy>=0.1.
|
|
21
|
+
"datus-db-core>=0.1.12",
|
|
22
|
+
"datus-sqlalchemy>=0.1.14",
|
|
23
23
|
"psycopg2-binary>=2.9.11",
|
|
24
24
|
"pydantic>=2.0.0",
|
|
25
25
|
"sqlglot>=30.0.0",
|
|
@@ -4,7 +4,7 @@ import pytest
|
|
|
4
4
|
|
|
5
5
|
from datus_db_core import DatusDbException, ErrorCode
|
|
6
6
|
from datus_postgresql import PostgreSQLConnector
|
|
7
|
-
from datus_sqlalchemy.testing import BlackholeProxy, assert_stalled_response_timeout
|
|
7
|
+
from datus_sqlalchemy.testing import BlackholeProxy, assert_query_timeout_override, assert_stalled_response_timeout
|
|
8
8
|
|
|
9
9
|
pytestmark = pytest.mark.integration
|
|
10
10
|
|
|
@@ -97,3 +97,15 @@ def test_reused_writer_validator_has_deadline_before_checkout_sql(config, engine
|
|
|
97
97
|
assert connection.execute(text("SELECT 42")).scalar_one() == 42
|
|
98
98
|
finally:
|
|
99
99
|
connector.close()
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_query_timeout_override_is_scoped_to_one_select(config):
|
|
103
|
+
# Keep the TLS fixture's resolved verify-full mode and CA while testing
|
|
104
|
+
# the community server's per-statement timeout.
|
|
105
|
+
config = config.model_copy(update={"aurora": False})
|
|
106
|
+
assert_query_timeout_override(
|
|
107
|
+
config,
|
|
108
|
+
PostgreSQLConnector,
|
|
109
|
+
"SELECT setting AS deadline FROM pg_settings WHERE name = 'statement_timeout'",
|
|
110
|
+
units_per_second=1000,
|
|
111
|
+
)
|
|
@@ -342,3 +342,35 @@ def test_connector_timeout_wiring_in_base_and_database_engines(overrides, expect
|
|
|
342
342
|
)
|
|
343
343
|
finally:
|
|
344
344
|
connector.close()
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
@pytest.mark.parametrize(
|
|
348
|
+
"overrides, dialect, expected",
|
|
349
|
+
[
|
|
350
|
+
({}, "postgresql", True),
|
|
351
|
+
({}, "greenplum", True),
|
|
352
|
+
({"aurora": True, "sslrootcert": "/tmp/ca.pem"}, "postgresql", False),
|
|
353
|
+
({}, "dws", False),
|
|
354
|
+
({}, "gaussdb", False),
|
|
355
|
+
({}, "hologres", False),
|
|
356
|
+
],
|
|
357
|
+
)
|
|
358
|
+
def test_query_timeout_override_capability_and_scope(overrides, dialect, expected):
|
|
359
|
+
from datus_postgresql import PostgreSQLConnector
|
|
360
|
+
|
|
361
|
+
connector = PostgreSQLConnector(
|
|
362
|
+
{"host": "db.test", "username": "reader", "password": "test", "database": "app", **overrides}
|
|
363
|
+
)
|
|
364
|
+
connector.dialect = dialect
|
|
365
|
+
try:
|
|
366
|
+
assert connector.supports_query_timeout_override is expected
|
|
367
|
+
if expected:
|
|
368
|
+
conn = Mock()
|
|
369
|
+
applied = Mock()
|
|
370
|
+
conn.exec_driver_sql.return_value = applied
|
|
371
|
+
with connector._query_timeout_scope(conn, 9):
|
|
372
|
+
pass
|
|
373
|
+
conn.exec_driver_sql.assert_called_once_with("SET LOCAL statement_timeout = 9000")
|
|
374
|
+
applied.close.assert_called_once_with()
|
|
375
|
+
finally:
|
|
376
|
+
connector.close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datus_postgresql-0.1.12 → datus_postgresql-0.1.13}/tests/integration/test_metadata_retrieval.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|