sqlspec 0.48.2__py3-none-any.whl → 0.49.0__py3-none-any.whl
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.
- sqlspec/__init__.py +2 -2
- sqlspec/_typing.py +87 -84
- sqlspec/adapters/adbc/_typing.py +2 -3
- sqlspec/adapters/adbc/adk/store.py +10 -85
- sqlspec/adapters/adbc/config.py +15 -23
- sqlspec/adapters/adbc/core.py +204 -128
- sqlspec/adapters/adbc/data_dictionary.py +36 -12
- sqlspec/adapters/adbc/driver.py +109 -74
- sqlspec/adapters/adbc/events/store.py +6 -27
- sqlspec/adapters/adbc/litestar/store.py +11 -35
- sqlspec/adapters/adbc/type_converter.py +7 -31
- sqlspec/adapters/aiomysql/_typing.py +11 -13
- sqlspec/adapters/aiomysql/adk/store.py +0 -12
- sqlspec/adapters/aiomysql/config.py +15 -24
- sqlspec/adapters/aiomysql/core.py +9 -8
- sqlspec/adapters/aiomysql/data_dictionary.py +1 -1
- sqlspec/adapters/aiomysql/driver.py +4 -3
- sqlspec/adapters/aiomysql/events/store.py +4 -20
- sqlspec/adapters/aiomysql/litestar/store.py +2 -46
- sqlspec/adapters/aiosqlite/__init__.py +7 -1
- sqlspec/adapters/aiosqlite/_typing.py +2 -5
- sqlspec/adapters/aiosqlite/adk/store.py +38 -161
- sqlspec/adapters/aiosqlite/config.py +23 -36
- sqlspec/adapters/aiosqlite/core.py +46 -17
- sqlspec/adapters/aiosqlite/data_dictionary.py +8 -7
- sqlspec/adapters/aiosqlite/driver.py +0 -9
- sqlspec/adapters/aiosqlite/litestar/store.py +2 -27
- sqlspec/adapters/aiosqlite/pool.py +13 -3
- sqlspec/adapters/aiosqlite/type_converter.py +115 -0
- sqlspec/adapters/arrow_odbc/__init__.py +2 -0
- sqlspec/adapters/arrow_odbc/_typing.py +9 -10
- sqlspec/adapters/arrow_odbc/config.py +5 -5
- sqlspec/adapters/arrow_odbc/data_dictionary.py +22 -7
- sqlspec/adapters/arrow_odbc/driver.py +30 -13
- sqlspec/adapters/arrow_odbc/type_converter.py +1 -15
- sqlspec/adapters/asyncmy/_typing.py +15 -3
- sqlspec/adapters/asyncmy/adk/store.py +0 -12
- sqlspec/adapters/asyncmy/config.py +28 -34
- sqlspec/adapters/asyncmy/core.py +14 -15
- sqlspec/adapters/asyncmy/data_dictionary.py +1 -1
- sqlspec/adapters/asyncmy/driver.py +4 -3
- sqlspec/adapters/asyncmy/events/store.py +4 -20
- sqlspec/adapters/asyncmy/litestar/store.py +2 -46
- sqlspec/adapters/asyncpg/_typing.py +2 -3
- sqlspec/adapters/asyncpg/adk/store.py +8 -8
- sqlspec/adapters/asyncpg/config.py +48 -71
- sqlspec/adapters/asyncpg/core.py +7 -5
- sqlspec/adapters/asyncpg/data_dictionary.py +16 -25
- sqlspec/adapters/asyncpg/driver.py +54 -10
- sqlspec/adapters/asyncpg/events/_hub.py +4 -4
- sqlspec/adapters/asyncpg/events/backend.py +12 -12
- sqlspec/adapters/asyncpg/events/store.py +0 -13
- sqlspec/adapters/asyncpg/litestar/store.py +0 -37
- sqlspec/adapters/bigquery/_typing.py +2 -3
- sqlspec/adapters/bigquery/config.py +21 -37
- sqlspec/adapters/bigquery/core.py +112 -47
- sqlspec/adapters/bigquery/data_dictionary.py +3 -6
- sqlspec/adapters/bigquery/driver.py +37 -59
- sqlspec/adapters/bigquery/events/store.py +3 -32
- sqlspec/adapters/bigquery/litestar/store.py +7 -43
- sqlspec/adapters/bigquery/type_converter.py +7 -18
- sqlspec/adapters/cockroach_asyncpg/_typing.py +5 -5
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +4 -4
- sqlspec/adapters/cockroach_asyncpg/config.py +13 -4
- sqlspec/adapters/cockroach_asyncpg/core.py +16 -6
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +16 -13
- sqlspec/adapters/cockroach_asyncpg/driver.py +4 -4
- sqlspec/adapters/cockroach_psycopg/_typing.py +10 -11
- sqlspec/adapters/cockroach_psycopg/adk/store.py +40 -40
- sqlspec/adapters/cockroach_psycopg/config.py +4 -4
- sqlspec/adapters/cockroach_psycopg/core.py +17 -6
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +31 -13
- sqlspec/adapters/cockroach_psycopg/driver.py +6 -18
- sqlspec/adapters/duckdb/_typing.py +2 -3
- sqlspec/adapters/duckdb/adk/__init__.py +0 -4
- sqlspec/adapters/duckdb/adk/store.py +11 -122
- sqlspec/adapters/duckdb/config.py +12 -36
- sqlspec/adapters/duckdb/core.py +12 -12
- sqlspec/adapters/duckdb/data_dictionary.py +3 -6
- sqlspec/adapters/duckdb/driver.py +3 -20
- sqlspec/adapters/duckdb/events/store.py +3 -22
- sqlspec/adapters/duckdb/litestar/store.py +7 -39
- sqlspec/adapters/duckdb/pool.py +25 -14
- sqlspec/adapters/duckdb/type_converter.py +3 -36
- sqlspec/adapters/mssql_python/__init__.py +3 -0
- sqlspec/adapters/mssql_python/_typing.py +10 -11
- sqlspec/adapters/mssql_python/config.py +28 -8
- sqlspec/adapters/mssql_python/core.py +5 -0
- sqlspec/adapters/mssql_python/data_dictionary.py +16 -5
- sqlspec/adapters/mssql_python/driver.py +2 -0
- sqlspec/adapters/mssql_python/type_converter.py +6 -1
- sqlspec/adapters/mysqlconnector/_typing.py +11 -12
- sqlspec/adapters/mysqlconnector/adk/store.py +63 -71
- sqlspec/adapters/mysqlconnector/config.py +19 -17
- sqlspec/adapters/mysqlconnector/core.py +13 -9
- sqlspec/adapters/mysqlconnector/data_dictionary.py +1 -1
- sqlspec/adapters/mysqlconnector/driver.py +16 -2
- sqlspec/adapters/mysqlconnector/events/store.py +19 -19
- sqlspec/adapters/mysqlconnector/litestar/store.py +2 -1
- sqlspec/adapters/oracledb/__init__.py +2 -0
- sqlspec/adapters/oracledb/_json_handlers.py +46 -35
- sqlspec/adapters/oracledb/_typing.py +25 -36
- sqlspec/adapters/oracledb/_uuid_handlers.py +4 -33
- sqlspec/adapters/oracledb/_vector_handlers.py +5 -2
- sqlspec/adapters/oracledb/adk/store.py +5 -120
- sqlspec/adapters/oracledb/config.py +59 -86
- sqlspec/adapters/oracledb/core.py +33 -18
- sqlspec/adapters/oracledb/data_dictionary.py +52 -21
- sqlspec/adapters/oracledb/driver.py +32 -74
- sqlspec/adapters/oracledb/events/_hub.py +11 -11
- sqlspec/adapters/oracledb/events/backend.py +6 -5
- sqlspec/adapters/oracledb/events/store.py +7 -35
- sqlspec/adapters/oracledb/litestar/store.py +9 -119
- sqlspec/adapters/oracledb/migrations.py +21 -9
- sqlspec/adapters/oracledb/type_converter.py +0 -83
- sqlspec/adapters/psqlpy/__init__.py +2 -1
- sqlspec/adapters/psqlpy/_typing.py +2 -3
- sqlspec/adapters/psqlpy/adk/store.py +8 -8
- sqlspec/adapters/psqlpy/config.py +22 -47
- sqlspec/adapters/psqlpy/core.py +46 -68
- sqlspec/adapters/psqlpy/data_dictionary.py +16 -7
- sqlspec/adapters/psqlpy/driver.py +16 -14
- sqlspec/adapters/psqlpy/events/_hub.py +74 -24
- sqlspec/adapters/psqlpy/events/backend.py +12 -12
- sqlspec/adapters/psqlpy/litestar/store.py +0 -40
- sqlspec/adapters/psqlpy/type_converter.py +4 -12
- sqlspec/adapters/psycopg/_typing.py +16 -17
- sqlspec/adapters/psycopg/adk/store.py +87 -87
- sqlspec/adapters/psycopg/config.py +36 -82
- sqlspec/adapters/psycopg/core.py +3 -3
- sqlspec/adapters/psycopg/data_dictionary.py +31 -19
- sqlspec/adapters/psycopg/driver.py +29 -12
- sqlspec/adapters/psycopg/events/_hub.py +5 -4
- sqlspec/adapters/psycopg/events/backend.py +12 -12
- sqlspec/adapters/psycopg/litestar/store.py +6 -70
- sqlspec/adapters/psycopg/type_converter.py +28 -27
- sqlspec/adapters/pymysql/_typing.py +2 -3
- sqlspec/adapters/pymysql/adk/store.py +12 -18
- sqlspec/adapters/pymysql/config.py +4 -6
- sqlspec/adapters/pymysql/core.py +12 -8
- sqlspec/adapters/pymysql/data_dictionary.py +1 -1
- sqlspec/adapters/pymysql/driver.py +4 -0
- sqlspec/adapters/pymysql/litestar/store.py +2 -1
- sqlspec/adapters/pymysql/pool.py +9 -26
- sqlspec/adapters/spanner/_typing.py +2 -3
- sqlspec/adapters/spanner/adk/store.py +2 -1
- sqlspec/adapters/spanner/config.py +1 -12
- sqlspec/adapters/spanner/core.py +2 -2
- sqlspec/adapters/spanner/data_dictionary.py +3 -6
- sqlspec/adapters/spanner/driver.py +15 -10
- sqlspec/adapters/spanner/events/store.py +5 -24
- sqlspec/adapters/spanner/type_converter.py +19 -20
- sqlspec/adapters/sqlite/_typing.py +2 -3
- sqlspec/adapters/sqlite/adk/store.py +39 -171
- sqlspec/adapters/sqlite/config.py +20 -31
- sqlspec/adapters/sqlite/core.py +10 -10
- sqlspec/adapters/sqlite/data_dictionary.py +10 -9
- sqlspec/adapters/sqlite/driver.py +18 -19
- sqlspec/adapters/sqlite/litestar/store.py +7 -32
- sqlspec/adapters/sqlite/pool.py +1 -17
- sqlspec/adapters/sqlite/type_converter.py +3 -2
- sqlspec/base.py +364 -436
- sqlspec/builder/__init__.py +3 -3
- sqlspec/builder/_base.py +23 -88
- sqlspec/builder/_column.py +25 -80
- sqlspec/builder/_ddl.py +119 -170
- sqlspec/builder/_dml.py +2 -2
- sqlspec/builder/_explain.py +14 -41
- sqlspec/builder/_expression_wrappers.py +18 -1
- sqlspec/builder/_factory.py +17 -272
- sqlspec/builder/_insert.py +26 -128
- sqlspec/builder/_join.py +49 -111
- sqlspec/builder/_merge.py +27 -67
- sqlspec/builder/_parsing_utils.py +61 -52
- sqlspec/builder/_select.py +73 -161
- sqlspec/builder/_temporal.py +13 -28
- sqlspec/builder/_update.py +0 -30
- sqlspec/builder/_vector_distance.py +19 -29
- sqlspec/cli.py +23 -27
- sqlspec/config.py +190 -695
- sqlspec/core/__init__.py +53 -47
- sqlspec/core/cache.py +49 -74
- sqlspec/core/compiler.py +120 -112
- sqlspec/core/config_runtime.py +19 -13
- sqlspec/core/{_correlation.py → correlation.py} +18 -48
- sqlspec/core/explain.py +6 -6
- sqlspec/core/filters.py +118 -82
- sqlspec/core/metrics.py +4 -1
- sqlspec/core/parameters/_alignment.py +65 -48
- sqlspec/core/parameters/_converter.py +23 -14
- sqlspec/core/parameters/_processor.py +643 -614
- sqlspec/core/parameters/_transformers.py +36 -44
- sqlspec/core/parameters/_types.py +41 -52
- sqlspec/core/parameters/_validator.py +14 -24
- sqlspec/core/pipeline.py +47 -54
- sqlspec/core/query_modifiers.py +15 -24
- sqlspec/core/result/_base.py +58 -100
- sqlspec/core/splitter.py +45 -44
- sqlspec/core/sqlcommenter.py +0 -2
- sqlspec/core/stack.py +6 -2
- sqlspec/core/statement.py +168 -164
- sqlspec/core/type_converter.py +1 -1
- sqlspec/data_dictionary/__init__.py +35 -2
- sqlspec/data_dictionary/_loader.py +7 -4
- sqlspec/data_dictionary/_registry.py +2 -2
- sqlspec/data_dictionary/_types.py +200 -2
- sqlspec/data_dictionary/dialects/cockroachdb.py +1 -2
- sqlspec/data_dictionary/dialects/duckdb.py +1 -2
- sqlspec/data_dictionary/dialects/mssql.py +1 -7
- sqlspec/data_dictionary/dialects/mysql.py +1 -2
- sqlspec/data_dictionary/dialects/oracle.py +1 -1
- sqlspec/data_dictionary/dialects/postgres.py +1 -2
- sqlspec/data_dictionary/dialects/sqlite.py +1 -2
- sqlspec/data_dictionary/sql/oracle/columns.sql +1 -1
- sqlspec/data_dictionary/sql/oracle/foreign_keys.sql +1 -1
- sqlspec/data_dictionary/sql/oracle/indexes.sql +1 -1
- sqlspec/dialects/__init__.py +3 -3
- sqlspec/dialects/postgres/_paradedb.py +15 -20
- sqlspec/dialects/postgres/_pgvector.py +6 -6
- sqlspec/dialects/spanner/_generators.py +20 -18
- sqlspec/dialects/spanner/_spangres.py +7 -11
- sqlspec/dialects/spanner/_spanner.py +9 -14
- sqlspec/driver/_async.py +28 -141
- sqlspec/driver/_common.py +827 -863
- sqlspec/driver/_exception_handler.py +7 -7
- sqlspec/driver/_query_cache.py +7 -0
- sqlspec/driver/_sql_helpers.py +7 -10
- sqlspec/driver/_storage_helpers.py +3 -12
- sqlspec/driver/_sync.py +34 -151
- sqlspec/exceptions.py +28 -31
- sqlspec/extensions/adk/__init__.py +18 -18
- sqlspec/extensions/adk/artifact/__init__.py +0 -39
- sqlspec/extensions/adk/artifact/service.py +9 -27
- sqlspec/extensions/adk/artifact/store.py +31 -34
- sqlspec/extensions/adk/converters.py +7 -4
- sqlspec/extensions/adk/memory/__init__.py +23 -23
- sqlspec/extensions/adk/memory/converters.py +2 -2
- sqlspec/extensions/adk/memory/service.py +5 -61
- sqlspec/extensions/adk/memory/store.py +49 -80
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +43 -67
- sqlspec/extensions/adk/service.py +3 -19
- sqlspec/extensions/adk/store.py +51 -93
- sqlspec/extensions/events/_channel.py +15 -11
- sqlspec/extensions/events/_hints.py +3 -0
- sqlspec/extensions/events/_models.py +9 -8
- sqlspec/extensions/events/_names.py +27 -0
- sqlspec/extensions/events/_protocols.py +2 -2
- sqlspec/extensions/events/_queue.py +18 -9
- sqlspec/extensions/events/_store.py +10 -32
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +4 -4
- sqlspec/extensions/fastapi/extension.py +0 -128
- sqlspec/extensions/fastapi/providers.py +105 -27
- sqlspec/extensions/flask/__init__.py +0 -27
- sqlspec/extensions/flask/_utils.py +8 -6
- sqlspec/extensions/flask/extension.py +0 -27
- sqlspec/extensions/litestar/_utils.py +0 -7
- sqlspec/extensions/litestar/channels.py +1 -6
- sqlspec/extensions/litestar/cli.py +0 -4
- sqlspec/extensions/litestar/config.py +9 -45
- sqlspec/extensions/litestar/handlers.py +10 -6
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +43 -54
- sqlspec/extensions/litestar/plugin.py +44 -67
- sqlspec/extensions/litestar/providers.py +159 -48
- sqlspec/extensions/litestar/store.py +2 -33
- sqlspec/extensions/otel/__init__.py +10 -10
- sqlspec/extensions/prometheus/__init__.py +17 -16
- sqlspec/extensions/sanic/extension.py +14 -31
- sqlspec/extensions/starlette/_utils.py +8 -8
- sqlspec/extensions/starlette/extension.py +0 -27
- sqlspec/extensions/starlette/middleware.py +36 -45
- sqlspec/loader.py +94 -73
- sqlspec/migrations/base.py +53 -313
- sqlspec/migrations/commands.py +11 -117
- sqlspec/migrations/context.py +15 -15
- sqlspec/migrations/fix.py +9 -6
- sqlspec/migrations/loaders.py +20 -20
- sqlspec/migrations/runner.py +4 -2
- sqlspec/migrations/squash.py +14 -48
- sqlspec/migrations/templates.py +5 -6
- sqlspec/migrations/tracker.py +17 -31
- sqlspec/migrations/utils.py +2 -2
- sqlspec/migrations/validation.py +6 -48
- sqlspec/migrations/version.py +33 -107
- sqlspec/observability/_common.py +3 -1
- sqlspec/observability/_config.py +10 -13
- sqlspec/observability/_diagnostics.py +4 -4
- sqlspec/observability/_dispatcher.py +179 -67
- sqlspec/observability/_formatters/_aws.py +0 -12
- sqlspec/observability/_formatters/_azure.py +0 -12
- sqlspec/observability/_formatters/_base.py +0 -17
- sqlspec/observability/_formatters/_gcp.py +0 -12
- sqlspec/observability/_observer.py +3 -10
- sqlspec/observability/_runtime.py +138 -27
- sqlspec/observability/_sampling.py +0 -33
- sqlspec/observability/_spans.py +2 -2
- sqlspec/protocols.py +6 -19
- sqlspec/service.py +34 -16
- sqlspec/storage/__init__.py +5 -5
- sqlspec/storage/_paths.py +30 -1
- sqlspec/storage/_utils.py +36 -1
- sqlspec/storage/backends/base.py +2 -16
- sqlspec/storage/backends/fsspec.py +16 -51
- sqlspec/storage/backends/local.py +45 -46
- sqlspec/storage/backends/obstore.py +110 -179
- sqlspec/storage/pipeline.py +14 -37
- sqlspec/storage/registry.py +8 -21
- sqlspec/typing.py +81 -260
- sqlspec/utils/__init__.py +1 -1
- sqlspec/utils/arrow_helpers.py +0 -13
- sqlspec/utils/config_tools.py +6 -6
- sqlspec/utils/correlation.py +4 -1
- sqlspec/utils/deprecation.py +48 -22
- sqlspec/utils/fixtures.py +111 -109
- sqlspec/utils/logging.py +46 -39
- sqlspec/utils/module_loader.py +55 -0
- sqlspec/utils/portal.py +9 -23
- sqlspec/utils/schema.py +36 -175
- sqlspec/utils/serializers/_json.py +6 -9
- sqlspec/utils/sync_tools.py +1 -5
- sqlspec/utils/text.py +27 -3
- sqlspec/utils/type_converters.py +12 -15
- sqlspec/utils/type_guards.py +39 -134
- sqlspec/utils/uuids.py +26 -60
- {sqlspec-0.48.2.dist-info → sqlspec-0.49.0.dist-info}/METADATA +1 -1
- sqlspec-0.49.0.dist-info/RECORD +496 -0
- {sqlspec-0.48.2.dist-info → sqlspec-0.49.0.dist-info}/WHEEL +1 -1
- sqlspec/core/result/_io.py +0 -28
- sqlspec/dialects/_compat.py +0 -14
- sqlspec-0.48.2.dist-info/RECORD +0 -496
- {sqlspec-0.48.2.dist-info → sqlspec-0.49.0.dist-info}/entry_points.txt +0 -0
- {sqlspec-0.48.2.dist-info → sqlspec-0.49.0.dist-info}/licenses/LICENSE +0 -0
sqlspec/__init__.py
CHANGED
|
@@ -89,8 +89,6 @@ from sqlspec.observability import (
|
|
|
89
89
|
from sqlspec.typing import ConnectionT, PoolT, SchemaT, StatementParameters, SupportedSchemaModel
|
|
90
90
|
from sqlspec.utils.logging import suppress_erroneous_sqlglot_log_messages
|
|
91
91
|
|
|
92
|
-
suppress_erroneous_sqlglot_log_messages()
|
|
93
|
-
|
|
94
92
|
__all__ = (
|
|
95
93
|
"SQL",
|
|
96
94
|
"ArrowResult",
|
|
@@ -165,3 +163,5 @@ __all__ = (
|
|
|
165
163
|
"typing",
|
|
166
164
|
"utils",
|
|
167
165
|
)
|
|
166
|
+
|
|
167
|
+
suppress_erroneous_sqlglot_log_messages()
|
sqlspec/_typing.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Public consumers should import from :mod:`sqlspec.typing`. This module is kept
|
|
5
5
|
private because it centralizes optional dependency fallbacks, compatibility
|
|
6
|
-
aliases, and mypyc-excluded type boundaries
|
|
6
|
+
aliases, and mypyc-excluded type boundaries for package internals.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
import enum
|
|
@@ -14,7 +14,92 @@ from typing import Any, ClassVar, Final, Literal, Protocol, cast, runtime_checka
|
|
|
14
14
|
|
|
15
15
|
from typing_extensions import Self, TypeVar, dataclass_transform
|
|
16
16
|
|
|
17
|
-
from sqlspec.utils.module_loader import dependency_flag, module_available
|
|
17
|
+
from sqlspec.utils.module_loader import dependency_flag, import_optional, import_optional_attr, module_available
|
|
18
|
+
|
|
19
|
+
__all__ = (
|
|
20
|
+
"ALLOYDB_CONNECTOR_INSTALLED",
|
|
21
|
+
"ATTRS_INSTALLED",
|
|
22
|
+
"CATTRS_INSTALLED",
|
|
23
|
+
"CLOUD_SQL_CONNECTOR_INSTALLED",
|
|
24
|
+
"FSSPEC_INSTALLED",
|
|
25
|
+
"LITESTAR_INSTALLED",
|
|
26
|
+
"MSGSPEC_INSTALLED",
|
|
27
|
+
"NANOID_INSTALLED",
|
|
28
|
+
"NUMPY_INSTALLED",
|
|
29
|
+
"OBSTORE_INSTALLED",
|
|
30
|
+
"OPENTELEMETRY_INSTALLED",
|
|
31
|
+
"ORJSON_INSTALLED",
|
|
32
|
+
"PANDAS_INSTALLED",
|
|
33
|
+
"PGVECTOR_INSTALLED",
|
|
34
|
+
"POLARS_INSTALLED",
|
|
35
|
+
"PROMETHEUS_INSTALLED",
|
|
36
|
+
"PYARROW_INSTALLED",
|
|
37
|
+
"PYDANTIC_INSTALLED",
|
|
38
|
+
"UNSET",
|
|
39
|
+
"UNSET_STUB",
|
|
40
|
+
"UUID_UTILS_INSTALLED",
|
|
41
|
+
"ArrowRecordBatch",
|
|
42
|
+
"ArrowRecordBatchReader",
|
|
43
|
+
"ArrowRecordBatchReaderProtocol",
|
|
44
|
+
"ArrowRecordBatchResult",
|
|
45
|
+
"ArrowSchema",
|
|
46
|
+
"ArrowSchemaProtocol",
|
|
47
|
+
"ArrowTable",
|
|
48
|
+
"ArrowTableResult",
|
|
49
|
+
"AttrsInstance",
|
|
50
|
+
"AttrsInstanceStub",
|
|
51
|
+
"BaseModel",
|
|
52
|
+
"BaseModelStub",
|
|
53
|
+
"Counter",
|
|
54
|
+
"DTOData",
|
|
55
|
+
"DTODataStub",
|
|
56
|
+
"DataclassProtocol",
|
|
57
|
+
"Empty",
|
|
58
|
+
"EmptyEnum",
|
|
59
|
+
"EmptyType",
|
|
60
|
+
"FailFast",
|
|
61
|
+
"FailFastStub",
|
|
62
|
+
"Gauge",
|
|
63
|
+
"Histogram",
|
|
64
|
+
"NumpyArray",
|
|
65
|
+
"NumpyArrayStub",
|
|
66
|
+
"PandasDataFrame",
|
|
67
|
+
"PandasDataFrameProtocol",
|
|
68
|
+
"PolarsDataFrame",
|
|
69
|
+
"PolarsDataFrameProtocol",
|
|
70
|
+
"Span",
|
|
71
|
+
"Status",
|
|
72
|
+
"StatusCode",
|
|
73
|
+
"Struct",
|
|
74
|
+
"StructStub",
|
|
75
|
+
"T",
|
|
76
|
+
"T_co",
|
|
77
|
+
"Tracer",
|
|
78
|
+
"TypeAdapter",
|
|
79
|
+
"TypeAdapterStub",
|
|
80
|
+
"UnsetType",
|
|
81
|
+
"UnsetTypeStub",
|
|
82
|
+
"attrs_asdict",
|
|
83
|
+
"attrs_asdict_stub",
|
|
84
|
+
"attrs_define",
|
|
85
|
+
"attrs_define_stub",
|
|
86
|
+
"attrs_field",
|
|
87
|
+
"attrs_field_stub",
|
|
88
|
+
"attrs_fields",
|
|
89
|
+
"attrs_fields_stub",
|
|
90
|
+
"attrs_has",
|
|
91
|
+
"attrs_has_stub",
|
|
92
|
+
"cattrs_structure",
|
|
93
|
+
"cattrs_unstructure",
|
|
94
|
+
"convert",
|
|
95
|
+
"convert_stub",
|
|
96
|
+
"import_optional",
|
|
97
|
+
"import_optional_attr",
|
|
98
|
+
"module_available",
|
|
99
|
+
"msgspec_fields",
|
|
100
|
+
"msgspec_fields_stub",
|
|
101
|
+
"trace",
|
|
102
|
+
)
|
|
18
103
|
|
|
19
104
|
|
|
20
105
|
@runtime_checkable
|
|
@@ -630,85 +715,3 @@ PYDANTIC_INSTALLED = dependency_flag("pydantic")
|
|
|
630
715
|
ALLOYDB_CONNECTOR_INSTALLED = dependency_flag("google.cloud.alloydb.connector")
|
|
631
716
|
NANOID_INSTALLED = dependency_flag("fastnanoid")
|
|
632
717
|
UUID_UTILS_INSTALLED = dependency_flag("uuid_utils")
|
|
633
|
-
__all__ = (
|
|
634
|
-
"ALLOYDB_CONNECTOR_INSTALLED",
|
|
635
|
-
"ATTRS_INSTALLED",
|
|
636
|
-
"CATTRS_INSTALLED",
|
|
637
|
-
"CLOUD_SQL_CONNECTOR_INSTALLED",
|
|
638
|
-
"FSSPEC_INSTALLED",
|
|
639
|
-
"LITESTAR_INSTALLED",
|
|
640
|
-
"MSGSPEC_INSTALLED",
|
|
641
|
-
"NANOID_INSTALLED",
|
|
642
|
-
"NUMPY_INSTALLED",
|
|
643
|
-
"OBSTORE_INSTALLED",
|
|
644
|
-
"OPENTELEMETRY_INSTALLED",
|
|
645
|
-
"ORJSON_INSTALLED",
|
|
646
|
-
"PANDAS_INSTALLED",
|
|
647
|
-
"PGVECTOR_INSTALLED",
|
|
648
|
-
"POLARS_INSTALLED",
|
|
649
|
-
"PROMETHEUS_INSTALLED",
|
|
650
|
-
"PYARROW_INSTALLED",
|
|
651
|
-
"PYDANTIC_INSTALLED",
|
|
652
|
-
"UNSET",
|
|
653
|
-
"UNSET_STUB",
|
|
654
|
-
"UUID_UTILS_INSTALLED",
|
|
655
|
-
"ArrowRecordBatch",
|
|
656
|
-
"ArrowRecordBatchReader",
|
|
657
|
-
"ArrowRecordBatchReaderProtocol",
|
|
658
|
-
"ArrowRecordBatchResult",
|
|
659
|
-
"ArrowSchema",
|
|
660
|
-
"ArrowSchemaProtocol",
|
|
661
|
-
"ArrowTable",
|
|
662
|
-
"ArrowTableResult",
|
|
663
|
-
"AttrsInstance",
|
|
664
|
-
"AttrsInstanceStub",
|
|
665
|
-
"BaseModel",
|
|
666
|
-
"BaseModelStub",
|
|
667
|
-
"Counter",
|
|
668
|
-
"DTOData",
|
|
669
|
-
"DTODataStub",
|
|
670
|
-
"DataclassProtocol",
|
|
671
|
-
"Empty",
|
|
672
|
-
"EmptyEnum",
|
|
673
|
-
"EmptyType",
|
|
674
|
-
"FailFast",
|
|
675
|
-
"FailFastStub",
|
|
676
|
-
"Gauge",
|
|
677
|
-
"Histogram",
|
|
678
|
-
"NumpyArray",
|
|
679
|
-
"NumpyArrayStub",
|
|
680
|
-
"PandasDataFrame",
|
|
681
|
-
"PandasDataFrameProtocol",
|
|
682
|
-
"PolarsDataFrame",
|
|
683
|
-
"PolarsDataFrameProtocol",
|
|
684
|
-
"Span",
|
|
685
|
-
"Status",
|
|
686
|
-
"StatusCode",
|
|
687
|
-
"Struct",
|
|
688
|
-
"StructStub",
|
|
689
|
-
"T",
|
|
690
|
-
"T_co",
|
|
691
|
-
"Tracer",
|
|
692
|
-
"TypeAdapter",
|
|
693
|
-
"TypeAdapterStub",
|
|
694
|
-
"UnsetType",
|
|
695
|
-
"UnsetTypeStub",
|
|
696
|
-
"attrs_asdict",
|
|
697
|
-
"attrs_asdict_stub",
|
|
698
|
-
"attrs_define",
|
|
699
|
-
"attrs_define_stub",
|
|
700
|
-
"attrs_field",
|
|
701
|
-
"attrs_field_stub",
|
|
702
|
-
"attrs_fields",
|
|
703
|
-
"attrs_fields_stub",
|
|
704
|
-
"attrs_has",
|
|
705
|
-
"attrs_has_stub",
|
|
706
|
-
"cattrs_structure",
|
|
707
|
-
"cattrs_unstructure",
|
|
708
|
-
"convert",
|
|
709
|
-
"convert_stub",
|
|
710
|
-
"module_available",
|
|
711
|
-
"msgspec_fields",
|
|
712
|
-
"msgspec_fields_stub",
|
|
713
|
-
"trace",
|
|
714
|
-
)
|
sqlspec/adapters/adbc/_typing.py
CHANGED
|
@@ -28,6 +28,8 @@ if not TYPE_CHECKING:
|
|
|
28
28
|
AdbcConnection = _AdbcConnection
|
|
29
29
|
AdbcRawCursor = _AdbcRawCursor
|
|
30
30
|
|
|
31
|
+
__all__ = ("AdbcConnection", "AdbcCursor", "AdbcRawCursor", "AdbcSessionContext")
|
|
32
|
+
|
|
31
33
|
|
|
32
34
|
class AdbcCursor:
|
|
33
35
|
"""Context manager for cursor management."""
|
|
@@ -106,6 +108,3 @@ class AdbcSessionContext:
|
|
|
106
108
|
self._release_connection(self._connection)
|
|
107
109
|
self._connection = None
|
|
108
110
|
return None
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
__all__ = ("AdbcConnection", "AdbcCursor", "AdbcRawCursor", "AdbcSessionContext")
|
|
@@ -14,9 +14,10 @@ if TYPE_CHECKING:
|
|
|
14
14
|
from sqlspec.adapters.adbc.config import AdbcConfig
|
|
15
15
|
from sqlspec.extensions.adk import MemoryRecord
|
|
16
16
|
|
|
17
|
+
__all__ = ("AdbcADKMemoryStore", "AdbcADKStore")
|
|
18
|
+
|
|
17
19
|
logger = get_logger("sqlspec.adapters.adbc.adk.store")
|
|
18
20
|
|
|
19
|
-
__all__ = ("AdbcADKMemoryStore", "AdbcADKStore")
|
|
20
21
|
|
|
21
22
|
DIALECT_POSTGRESQL: Final = "postgresql"
|
|
22
23
|
DIALECT_SQLITE: Final = "sqlite"
|
|
@@ -35,46 +36,21 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
35
36
|
transfer across multiple databases (PostgreSQL, SQLite, DuckDB, etc.).
|
|
36
37
|
|
|
37
38
|
Events use the new 5-column contract: session_id, invocation_id, author,
|
|
38
|
-
timestamp, and event_json.
|
|
39
|
+
timestamp, and event_json. The full ADK Event payload is stored as a
|
|
39
40
|
single JSON blob in event_json using a dialect-appropriate column type
|
|
40
41
|
(JSONB for PostgreSQL, JSON for DuckDB, VARIANT for Snowflake, TEXT for
|
|
41
42
|
SQLite and generic fallback).
|
|
42
43
|
|
|
43
44
|
Provides:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
- Session state management with JSON serialization
|
|
46
|
+
- Event history tracking via single event_json blob
|
|
47
|
+
- Atomic event insert + session state update
|
|
48
|
+
- Timezone-aware timestamps
|
|
49
|
+
- Foreign key constraints with cascade delete
|
|
50
|
+
- Database-agnostic SQL (supports multiple backends)
|
|
50
51
|
|
|
51
52
|
Args:
|
|
52
53
|
config: AdbcConfig with extension_config["adk"] settings.
|
|
53
|
-
|
|
54
|
-
Example:
|
|
55
|
-
from sqlspec.adapters.adbc import AdbcConfig
|
|
56
|
-
from sqlspec.adapters.adbc.adk import AdbcADKStore
|
|
57
|
-
|
|
58
|
-
config = AdbcConfig(
|
|
59
|
-
connection_config={"driver_name": "sqlite", "uri": ":memory:"},
|
|
60
|
-
extension_config={
|
|
61
|
-
"adk": {
|
|
62
|
-
"session_table": "my_sessions",
|
|
63
|
-
"events_table": "my_events",
|
|
64
|
-
"owner_id_column": "tenant_id INTEGER REFERENCES tenants(id)"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
)
|
|
68
|
-
store = AdbcADKStore(config)
|
|
69
|
-
store.ensure_tables()
|
|
70
|
-
|
|
71
|
-
Notes:
|
|
72
|
-
- Dialect-appropriate JSON type for event_json storage
|
|
73
|
-
- TIMESTAMP for timezone-aware timestamps (driver-dependent precision)
|
|
74
|
-
- Parameter style: ``?`` universally across ADBC backends
|
|
75
|
-
- State and JSON fields use to_json/from_json for serialization
|
|
76
|
-
- ADBC drivers handle parameter binding automatically
|
|
77
|
-
- Configuration is read from config.extension_config["adk"]
|
|
78
54
|
"""
|
|
79
55
|
|
|
80
56
|
__slots__ = ("_dialect",)
|
|
@@ -84,12 +60,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
84
60
|
|
|
85
61
|
Args:
|
|
86
62
|
config: AdbcConfig instance (any ADBC driver).
|
|
87
|
-
|
|
88
|
-
Notes:
|
|
89
|
-
Configuration is read from config.extension_config["adk"]:
|
|
90
|
-
- session_table: Sessions table name (default: "adk_sessions")
|
|
91
|
-
- events_table: Events table name (default: "adk_events")
|
|
92
|
-
- owner_id_column: Optional owner FK column DDL (default: None)
|
|
93
63
|
"""
|
|
94
64
|
super().__init__(config)
|
|
95
65
|
self._dialect = self._detect_dialect()
|
|
@@ -104,10 +74,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
104
74
|
|
|
105
75
|
Returns:
|
|
106
76
|
Dialect identifier for DDL generation.
|
|
107
|
-
|
|
108
|
-
Notes:
|
|
109
|
-
Reads from config.connection_config driver_name.
|
|
110
|
-
Falls back to generic for unknown drivers.
|
|
111
77
|
"""
|
|
112
78
|
driver_name = self._config.connection_config.get("driver_name", "").lower()
|
|
113
79
|
|
|
@@ -304,9 +270,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
304
270
|
|
|
305
271
|
Returns:
|
|
306
272
|
SQL to create events table optimized for PostgreSQL.
|
|
307
|
-
|
|
308
|
-
Notes:
|
|
309
|
-
Uses JSONB for event_json to enable indexing and query support.
|
|
310
273
|
"""
|
|
311
274
|
return f"""
|
|
312
275
|
CREATE TABLE IF NOT EXISTS {self._events_table} (
|
|
@@ -324,9 +287,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
324
287
|
|
|
325
288
|
Returns:
|
|
326
289
|
SQL to create events table optimized for SQLite.
|
|
327
|
-
|
|
328
|
-
Notes:
|
|
329
|
-
Uses TEXT for event_json (SQLite has no native JSON column type).
|
|
330
290
|
"""
|
|
331
291
|
return f"""
|
|
332
292
|
CREATE TABLE IF NOT EXISTS {self._events_table} (
|
|
@@ -344,9 +304,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
344
304
|
|
|
345
305
|
Returns:
|
|
346
306
|
SQL to create events table optimized for DuckDB.
|
|
347
|
-
|
|
348
|
-
Notes:
|
|
349
|
-
Uses JSON for event_json (DuckDB native JSON type).
|
|
350
307
|
"""
|
|
351
308
|
return f"""
|
|
352
309
|
CREATE TABLE IF NOT EXISTS {self._events_table} (
|
|
@@ -364,9 +321,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
364
321
|
|
|
365
322
|
Returns:
|
|
366
323
|
SQL to create events table optimized for Snowflake.
|
|
367
|
-
|
|
368
|
-
Notes:
|
|
369
|
-
Uses VARIANT for event_json (Snowflake semi-structured type).
|
|
370
324
|
"""
|
|
371
325
|
return f"""
|
|
372
326
|
CREATE TABLE IF NOT EXISTS {self._events_table} (
|
|
@@ -384,9 +338,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
384
338
|
|
|
385
339
|
Returns:
|
|
386
340
|
SQL to create events table using generic types.
|
|
387
|
-
|
|
388
|
-
Notes:
|
|
389
|
-
Uses TEXT for event_json (maximum portability).
|
|
390
341
|
"""
|
|
391
342
|
return f"""
|
|
392
343
|
CREATE TABLE IF NOT EXISTS {self._events_table} (
|
|
@@ -404,10 +355,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
404
355
|
|
|
405
356
|
Returns:
|
|
406
357
|
List of SQL statements to drop tables and indexes.
|
|
407
|
-
|
|
408
|
-
Notes:
|
|
409
|
-
Order matters: drop events table (child) before sessions (parent).
|
|
410
|
-
Most databases automatically drop indexes when dropping tables.
|
|
411
358
|
"""
|
|
412
359
|
return [f"DROP TABLE IF EXISTS {self._events_table}", f"DROP TABLE IF EXISTS {self._session_table}"]
|
|
413
360
|
|
|
@@ -457,10 +404,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
457
404
|
Args:
|
|
458
405
|
cursor: Database cursor.
|
|
459
406
|
conn: Database connection.
|
|
460
|
-
|
|
461
|
-
Notes:
|
|
462
|
-
SQLite requires PRAGMA foreign_keys = ON to be set per connection.
|
|
463
|
-
This is a no-op for other databases.
|
|
464
407
|
"""
|
|
465
408
|
try:
|
|
466
409
|
cursor.execute("PRAGMA foreign_keys = ON")
|
|
@@ -528,9 +471,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
528
471
|
|
|
529
472
|
Returns:
|
|
530
473
|
Session record or None if not found.
|
|
531
|
-
|
|
532
|
-
Notes:
|
|
533
|
-
State is deserialized from JSON string.
|
|
534
474
|
"""
|
|
535
475
|
sql = f"""
|
|
536
476
|
SELECT id, app_name, user_id, state, create_time, update_time
|
|
@@ -574,10 +514,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
574
514
|
Args:
|
|
575
515
|
session_id: Session identifier.
|
|
576
516
|
state: New state dictionary (replaces existing state).
|
|
577
|
-
|
|
578
|
-
Notes:
|
|
579
|
-
This replaces the entire state dictionary.
|
|
580
|
-
Updates update_time to current timestamp.
|
|
581
517
|
"""
|
|
582
518
|
state_json = self._serialize_state(state)
|
|
583
519
|
sql = f"""
|
|
@@ -603,9 +539,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
603
539
|
|
|
604
540
|
Args:
|
|
605
541
|
session_id: Session identifier.
|
|
606
|
-
|
|
607
|
-
Notes:
|
|
608
|
-
Foreign key constraint ensures events are cascade-deleted.
|
|
609
542
|
"""
|
|
610
543
|
sql = f"DELETE FROM {self._session_table} WHERE id = ?"
|
|
611
544
|
|
|
@@ -631,9 +564,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
631
564
|
|
|
632
565
|
Returns:
|
|
633
566
|
List of session records ordered by update_time DESC.
|
|
634
|
-
|
|
635
|
-
Notes:
|
|
636
|
-
Uses composite index on (app_name, user_id) when user_id is provided.
|
|
637
567
|
"""
|
|
638
568
|
if user_id is None:
|
|
639
569
|
sql = f"""
|
|
@@ -718,7 +648,7 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
718
648
|
"""Atomically insert an event and update the session's durable state.
|
|
719
649
|
|
|
720
650
|
The event insert, state update, and refresh-SELECT are executed within
|
|
721
|
-
a single connection and committed together.
|
|
651
|
+
a single connection and committed together. ADBC drivers wrap a
|
|
722
652
|
variety of backends (Postgres, SQLite, DuckDB, ...) so we use a
|
|
723
653
|
SELECT-after-UPDATE rather than relying on RETURNING which not every
|
|
724
654
|
backend supports.
|
|
@@ -802,11 +732,6 @@ class AdbcADKStore(BaseAsyncADKStore["AdbcConfig"]):
|
|
|
802
732
|
|
|
803
733
|
Returns:
|
|
804
734
|
List of event records ordered by timestamp ASC.
|
|
805
|
-
|
|
806
|
-
Notes:
|
|
807
|
-
Uses index on (session_id, timestamp ASC).
|
|
808
|
-
Returns the 5-column EventRecord (session_id, invocation_id,
|
|
809
|
-
author, timestamp, event_json).
|
|
810
735
|
"""
|
|
811
736
|
where_clauses = ["session_id = ?"]
|
|
812
737
|
params: list[Any] = [session_id]
|
sqlspec/adapters/adbc/config.py
CHANGED
|
@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, ClassVar, TypedDict, cast
|
|
|
4
4
|
|
|
5
5
|
from typing_extensions import NotRequired
|
|
6
6
|
|
|
7
|
-
from sqlspec.adapters.adbc._typing import AdbcConnection
|
|
7
|
+
from sqlspec.adapters.adbc._typing import AdbcConnection, AdbcCursor, AdbcSessionContext
|
|
8
8
|
from sqlspec.adapters.adbc.core import (
|
|
9
9
|
apply_driver_features,
|
|
10
10
|
build_connection_config,
|
|
@@ -17,7 +17,7 @@ from sqlspec.adapters.adbc.core import (
|
|
|
17
17
|
resolve_postgres_extension_state,
|
|
18
18
|
resolve_runtime_statement_config,
|
|
19
19
|
)
|
|
20
|
-
from sqlspec.adapters.adbc.driver import
|
|
20
|
+
from sqlspec.adapters.adbc.driver import AdbcDriver, AdbcExceptionHandler
|
|
21
21
|
from sqlspec.config import ExtensionConfigs, NoPoolSyncConfig
|
|
22
22
|
from sqlspec.core import StatementConfig
|
|
23
23
|
from sqlspec.driver._sync import SyncPoolConnectionContext, SyncPoolSessionFactory
|
|
@@ -78,20 +78,20 @@ class AdbcDriverFeatures(TypedDict):
|
|
|
78
78
|
Attributes:
|
|
79
79
|
json_serializer: JSON serialization function to use.
|
|
80
80
|
Callable that takes Any and returns str (JSON string).
|
|
81
|
-
|
|
81
|
+
Default: sqlspec.utils.serializers.to_json
|
|
82
82
|
enable_cast_detection: Enable cast-aware parameter processing.
|
|
83
|
-
When True, detects SQL casts
|
|
83
|
+
When True, detects SQL casts and applies appropriate
|
|
84
84
|
serialization. Currently used for PostgreSQL JSONB handling.
|
|
85
|
-
|
|
85
|
+
Default: True
|
|
86
86
|
enable_strict_type_coercion: Enforce strict type coercion rules.
|
|
87
87
|
When True, raises errors for unsupported type conversions.
|
|
88
88
|
When False, attempts best-effort conversion.
|
|
89
|
-
|
|
89
|
+
Default: False
|
|
90
90
|
strict_type_coercion: Alias for enable_strict_type_coercion.
|
|
91
91
|
enable_arrow_extension_types: Enable PyArrow extension type support.
|
|
92
92
|
When True, preserves Arrow extension type metadata when reading data.
|
|
93
93
|
When False, falls back to storage types.
|
|
94
|
-
|
|
94
|
+
Default: True
|
|
95
95
|
arrow_extension_types: Alias for enable_arrow_extension_types.
|
|
96
96
|
enable_pgvector: Enable automatic pgvector extension detection.
|
|
97
97
|
When True and the resolved dialect is PostgreSQL, queries ``pg_extension``
|
|
@@ -106,7 +106,7 @@ class AdbcDriverFeatures(TypedDict):
|
|
|
106
106
|
Provides pub/sub capabilities via table-backed queue (ADBC has no native pub/sub).
|
|
107
107
|
Requires extension_config["events"] for migration setup.
|
|
108
108
|
events_backend: Event channel backend selection.
|
|
109
|
-
|
|
109
|
+
Only option: "table_queue" (durable table-backed queue with retries and exactly-once delivery).
|
|
110
110
|
ADBC does not have native pub/sub, so table_queue is the only backend.
|
|
111
111
|
Defaults to "table_queue".
|
|
112
112
|
"""
|
|
@@ -171,14 +171,6 @@ class AdbcConfig(NoPoolSyncConfig[AdbcConnection, AdbcDriver]):
|
|
|
171
171
|
|
|
172
172
|
Supports multiple database backends including PostgreSQL, SQLite, DuckDB,
|
|
173
173
|
BigQuery, and Snowflake with automatic driver detection and loading.
|
|
174
|
-
|
|
175
|
-
Example::
|
|
176
|
-
|
|
177
|
-
config = AdbcConfig(
|
|
178
|
-
connection_config=AdbcConnectionParams(
|
|
179
|
-
uri="postgresql://user:pass@localhost/db"
|
|
180
|
-
)
|
|
181
|
-
)
|
|
182
174
|
"""
|
|
183
175
|
|
|
184
176
|
driver_type: ClassVar[type[AdbcDriver]] = AdbcDriver
|
|
@@ -193,6 +185,7 @@ class AdbcConfig(NoPoolSyncConfig[AdbcConnection, AdbcDriver]):
|
|
|
193
185
|
_session_factory_class: "ClassVar[type[_AdbcSessionConnectionHandler]]" = _AdbcSessionConnectionHandler
|
|
194
186
|
_session_context_class: "ClassVar[type[AdbcSessionContext]]" = AdbcSessionContext
|
|
195
187
|
_default_statement_config = StatementConfig()
|
|
188
|
+
__slots__ = ("_default_session_config", "_paradedb_available", "_pgvector_available", "_resolved_dialect")
|
|
196
189
|
|
|
197
190
|
def __init__(
|
|
198
191
|
self,
|
|
@@ -216,7 +209,7 @@ class AdbcConfig(NoPoolSyncConfig[AdbcConnection, AdbcDriver]):
|
|
|
216
209
|
statement_config: Default SQL statement configuration
|
|
217
210
|
driver_features: Driver feature configuration (AdbcDriverFeatures)
|
|
218
211
|
bind_key: Optional unique identifier for this configuration
|
|
219
|
-
extension_config: Extension-specific configuration
|
|
212
|
+
extension_config: Extension-specific configuration
|
|
220
213
|
observability_config: Adapter-level observability overrides for lifecycle hooks and observers
|
|
221
214
|
**kwargs: Additional keyword arguments passed to the base configuration.
|
|
222
215
|
"""
|
|
@@ -224,12 +217,13 @@ class AdbcConfig(NoPoolSyncConfig[AdbcConnection, AdbcDriver]):
|
|
|
224
217
|
self._pgvector_available: bool | None = None
|
|
225
218
|
self._paradedb_available: bool | None = None
|
|
226
219
|
|
|
227
|
-
|
|
220
|
+
self._resolved_dialect = resolve_dialect_from_config(self.connection_config)
|
|
228
221
|
|
|
229
222
|
if statement_config is None:
|
|
230
|
-
statement_config = get_statement_config(
|
|
223
|
+
statement_config = get_statement_config(self._resolved_dialect)
|
|
231
224
|
|
|
232
225
|
statement_config, driver_features = apply_driver_features(statement_config, driver_features)
|
|
226
|
+
self._default_session_config = get_statement_config(self._resolved_dialect)
|
|
233
227
|
|
|
234
228
|
super().__init__(
|
|
235
229
|
connection_config=self.connection_config,
|
|
@@ -246,7 +240,7 @@ class AdbcConfig(NoPoolSyncConfig[AdbcConnection, AdbcDriver]):
|
|
|
246
240
|
@property
|
|
247
241
|
def supports_migration_schemas(self) -> bool: # type: ignore[override]
|
|
248
242
|
"""Migration schema support is only available for PostgreSQL-backed ADBC drivers."""
|
|
249
|
-
return is_postgres_dialect(
|
|
243
|
+
return is_postgres_dialect(self._resolved_dialect)
|
|
250
244
|
|
|
251
245
|
def create_connection(self) -> AdbcConnection:
|
|
252
246
|
"""Create and return a new connection using the specified driver.
|
|
@@ -346,9 +340,7 @@ class AdbcConfig(NoPoolSyncConfig[AdbcConnection, AdbcDriver]):
|
|
|
346
340
|
"""
|
|
347
341
|
self._detect_extensions_if_needed()
|
|
348
342
|
statement_config = resolve_runtime_statement_config(
|
|
349
|
-
statement_config,
|
|
350
|
-
self.statement_config,
|
|
351
|
-
get_statement_config(resolve_dialect_from_config(self.connection_config)),
|
|
343
|
+
statement_config, self.statement_config, self._default_session_config
|
|
352
344
|
)
|
|
353
345
|
handler = _AdbcSessionConnectionHandler(self)
|
|
354
346
|
|