sqlspec 0.47.0__cp314-cp314-win_amd64.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.
- f68e0789eb443ecb1c2c__mypyc.cp314-win_amd64.pyd +0 -0
- sqlspec/__init__.py +167 -0
- sqlspec/__main__.py +12 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_typing.py +714 -0
- sqlspec/adapters/__init__.py +0 -0
- sqlspec/adapters/adbc/__init__.py +13 -0
- sqlspec/adapters/adbc/_typing.py +106 -0
- sqlspec/adapters/adbc/adk/__init__.py +5 -0
- sqlspec/adapters/adbc/adk/store.py +1280 -0
- sqlspec/adapters/adbc/config.py +378 -0
- sqlspec/adapters/adbc/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/core.py +922 -0
- sqlspec/adapters/adbc/data_dictionary.py +339 -0
- sqlspec/adapters/adbc/driver.py +534 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +285 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +534 -0
- sqlspec/adapters/adbc/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/type_converter.py +142 -0
- sqlspec/adapters/aiomysql/__init__.py +21 -0
- sqlspec/adapters/aiomysql/_typing.py +137 -0
- sqlspec/adapters/aiomysql/adk/__init__.py +5 -0
- sqlspec/adapters/aiomysql/adk/store.py +678 -0
- sqlspec/adapters/aiomysql/config.py +305 -0
- sqlspec/adapters/aiomysql/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/core.py +536 -0
- sqlspec/adapters/aiomysql/data_dictionary.py +121 -0
- sqlspec/adapters/aiomysql/driver.py +386 -0
- sqlspec/adapters/aiomysql/events/__init__.py +5 -0
- sqlspec/adapters/aiomysql/events/store.py +104 -0
- sqlspec/adapters/aiomysql/litestar/__init__.py +5 -0
- sqlspec/adapters/aiomysql/litestar/store.py +314 -0
- sqlspec/adapters/aiosqlite/__init__.py +26 -0
- sqlspec/adapters/aiosqlite/_typing.py +109 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +829 -0
- sqlspec/adapters/aiosqlite/config.py +315 -0
- sqlspec/adapters/aiosqlite/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/core.py +315 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +202 -0
- sqlspec/adapters/aiosqlite/driver.py +311 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +20 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +279 -0
- sqlspec/adapters/aiosqlite/pool.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/pool.py +734 -0
- sqlspec/adapters/asyncmy/__init__.py +21 -0
- sqlspec/adapters/asyncmy/_typing.py +113 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +644 -0
- sqlspec/adapters/asyncmy/config.py +307 -0
- sqlspec/adapters/asyncmy/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/core.py +538 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +122 -0
- sqlspec/adapters/asyncmy/driver.py +391 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +104 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +296 -0
- sqlspec/adapters/asyncpg/__init__.py +26 -0
- sqlspec/adapters/asyncpg/_typing.py +103 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +483 -0
- sqlspec/adapters/asyncpg/config.py +575 -0
- sqlspec/adapters/asyncpg/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/core.py +480 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +157 -0
- sqlspec/adapters/asyncpg/driver.py +487 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/_hub.py +181 -0
- sqlspec/adapters/asyncpg/events/backend.py +210 -0
- sqlspec/adapters/asyncpg/events/store.py +40 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +251 -0
- sqlspec/adapters/bigquery/__init__.py +15 -0
- sqlspec/adapters/bigquery/_typing.py +108 -0
- sqlspec/adapters/bigquery/config.py +362 -0
- sqlspec/adapters/bigquery/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/core.py +768 -0
- sqlspec/adapters/bigquery/data_dictionary.py +120 -0
- sqlspec/adapters/bigquery/driver.py +542 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +139 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +325 -0
- sqlspec/adapters/bigquery/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/type_converter.py +107 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +26 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +73 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +465 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +248 -0
- sqlspec/adapters/cockroach_asyncpg/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +55 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +110 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +142 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +142 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +39 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +137 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +13 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +1039 -0
- sqlspec/adapters/cockroach_psycopg/config.py +511 -0
- sqlspec/adapters/cockroach_psycopg/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +63 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +220 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +273 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +6 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +3 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +327 -0
- sqlspec/adapters/duckdb/__init__.py +29 -0
- sqlspec/adapters/duckdb/_typing.py +104 -0
- sqlspec/adapters/duckdb/adk/__init__.py +14 -0
- sqlspec/adapters/duckdb/adk/store.py +935 -0
- sqlspec/adapters/duckdb/config.py +386 -0
- sqlspec/adapters/duckdb/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/core.py +332 -0
- sqlspec/adapters/duckdb/data_dictionary.py +140 -0
- sqlspec/adapters/duckdb/driver.py +426 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +57 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +330 -0
- sqlspec/adapters/duckdb/pool.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/pool.py +350 -0
- sqlspec/adapters/duckdb/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/type_converter.py +118 -0
- sqlspec/adapters/mysqlconnector/__init__.py +39 -0
- sqlspec/adapters/mysqlconnector/_typing.py +186 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +15 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +1183 -0
- sqlspec/adapters/mysqlconnector/config.py +421 -0
- sqlspec/adapters/mysqlconnector/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/core.py +472 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +230 -0
- sqlspec/adapters/mysqlconnector/driver.py +516 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +98 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +5 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +426 -0
- sqlspec/adapters/oracledb/__init__.py +39 -0
- sqlspec/adapters/oracledb/_json_handlers.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_json_handlers.py +196 -0
- sqlspec/adapters/oracledb/_param_types.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_param_types.py +46 -0
- sqlspec/adapters/oracledb/_typing.py +258 -0
- sqlspec/adapters/oracledb/_uuid_handlers.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +163 -0
- sqlspec/adapters/oracledb/_vector_handlers.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_vector_handlers.py +228 -0
- sqlspec/adapters/oracledb/adk/__init__.py +21 -0
- sqlspec/adapters/oracledb/adk/store.py +2453 -0
- sqlspec/adapters/oracledb/config.py +575 -0
- sqlspec/adapters/oracledb/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/core.py +820 -0
- sqlspec/adapters/oracledb/data_dictionary.py +404 -0
- sqlspec/adapters/oracledb/driver.py +1277 -0
- sqlspec/adapters/oracledb/events/__init__.py +16 -0
- sqlspec/adapters/oracledb/events/_hub.py +345 -0
- sqlspec/adapters/oracledb/events/backend.py +300 -0
- sqlspec/adapters/oracledb/events/store.py +420 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +5 -0
- sqlspec/adapters/oracledb/litestar/store.py +781 -0
- sqlspec/adapters/oracledb/migrations.py +539 -0
- sqlspec/adapters/oracledb/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/type_converter.py +211 -0
- sqlspec/adapters/psqlpy/__init__.py +18 -0
- sqlspec/adapters/psqlpy/_typing.py +121 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +591 -0
- sqlspec/adapters/psqlpy/config.py +376 -0
- sqlspec/adapters/psqlpy/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/core.py +694 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +121 -0
- sqlspec/adapters/psqlpy/driver.py +411 -0
- sqlspec/adapters/psqlpy/events/__init__.py +6 -0
- sqlspec/adapters/psqlpy/events/_hub.py +204 -0
- sqlspec/adapters/psqlpy/events/backend.py +210 -0
- sqlspec/adapters/psqlpy/events/store.py +20 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +113 -0
- sqlspec/adapters/psycopg/__init__.py +38 -0
- sqlspec/adapters/psycopg/_typing.py +218 -0
- sqlspec/adapters/psycopg/adk/__init__.py +10 -0
- sqlspec/adapters/psycopg/adk/store.py +1106 -0
- sqlspec/adapters/psycopg/config.py +695 -0
- sqlspec/adapters/psycopg/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/core.py +520 -0
- sqlspec/adapters/psycopg/data_dictionary.py +278 -0
- sqlspec/adapters/psycopg/driver.py +1033 -0
- sqlspec/adapters/psycopg/events/__init__.py +20 -0
- sqlspec/adapters/psycopg/events/_hub.py +388 -0
- sqlspec/adapters/psycopg/events/backend.py +398 -0
- sqlspec/adapters/psycopg/events/store.py +42 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +554 -0
- sqlspec/adapters/psycopg/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/type_converter.py +93 -0
- sqlspec/adapters/pymysql/__init__.py +21 -0
- sqlspec/adapters/pymysql/_typing.py +92 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +657 -0
- sqlspec/adapters/pymysql/config.py +176 -0
- sqlspec/adapters/pymysql/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/core.py +469 -0
- sqlspec/adapters/pymysql/data_dictionary.py +120 -0
- sqlspec/adapters/pymysql/driver.py +271 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +50 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +232 -0
- sqlspec/adapters/pymysql/pool.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/pool.py +184 -0
- sqlspec/adapters/spanner/__init__.py +33 -0
- sqlspec/adapters/spanner/_typing.py +102 -0
- sqlspec/adapters/spanner/adk/__init__.py +5 -0
- sqlspec/adapters/spanner/adk/store.py +758 -0
- sqlspec/adapters/spanner/config.py +355 -0
- sqlspec/adapters/spanner/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/core.py +263 -0
- sqlspec/adapters/spanner/data_dictionary.py +120 -0
- sqlspec/adapters/spanner/driver.py +407 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +187 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +291 -0
- sqlspec/adapters/spanner/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/type_converter.py +342 -0
- sqlspec/adapters/sqlite/__init__.py +19 -0
- sqlspec/adapters/sqlite/_typing.py +123 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +992 -0
- sqlspec/adapters/sqlite/config.py +240 -0
- sqlspec/adapters/sqlite/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/core.py +357 -0
- sqlspec/adapters/sqlite/data_dictionary.py +198 -0
- sqlspec/adapters/sqlite/driver.py +527 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +20 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +316 -0
- sqlspec/adapters/sqlite/pool.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/pool.py +237 -0
- sqlspec/adapters/sqlite/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/base.py +832 -0
- sqlspec/builder/__init__.py +181 -0
- sqlspec/builder/_base.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_base.py +1071 -0
- sqlspec/builder/_column.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_column.py +521 -0
- sqlspec/builder/_ddl.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_ddl.py +1691 -0
- sqlspec/builder/_delete.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_delete.py +95 -0
- sqlspec/builder/_dml.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_dml.py +386 -0
- sqlspec/builder/_explain.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_explain.py +579 -0
- sqlspec/builder/_expression_wrappers.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_expression_wrappers.py +46 -0
- sqlspec/builder/_factory.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_factory.py +1884 -0
- sqlspec/builder/_insert.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_insert.py +405 -0
- sqlspec/builder/_join.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_join.py +489 -0
- sqlspec/builder/_merge.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_merge.py +823 -0
- sqlspec/builder/_parsing_utils.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_parsing_utils.py +295 -0
- sqlspec/builder/_select.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_select.py +1666 -0
- sqlspec/builder/_temporal.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_temporal.py +167 -0
- sqlspec/builder/_update.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_update.py +173 -0
- sqlspec/builder/_vector_distance.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_vector_distance.py +330 -0
- sqlspec/cli.py +1095 -0
- sqlspec/config.py +2383 -0
- sqlspec/core/__init__.py +372 -0
- sqlspec/core/_correlation.cp314-win_amd64.pyd +0 -0
- sqlspec/core/_correlation.py +176 -0
- sqlspec/core/_pagination.py +42 -0
- sqlspec/core/_pool.cp314-win_amd64.pyd +0 -0
- sqlspec/core/_pool.py +76 -0
- sqlspec/core/cache.cp314-win_amd64.pyd +0 -0
- sqlspec/core/cache.py +1085 -0
- sqlspec/core/compiler.cp314-win_amd64.pyd +0 -0
- sqlspec/core/compiler.py +1090 -0
- sqlspec/core/config_runtime.cp314-win_amd64.pyd +0 -0
- sqlspec/core/config_runtime.py +174 -0
- sqlspec/core/explain.cp314-win_amd64.pyd +0 -0
- sqlspec/core/explain.py +275 -0
- sqlspec/core/filters.cp314-win_amd64.pyd +0 -0
- sqlspec/core/filters.py +969 -0
- sqlspec/core/hashing.cp314-win_amd64.pyd +0 -0
- sqlspec/core/hashing.py +266 -0
- sqlspec/core/metrics.cp314-win_amd64.pyd +0 -0
- sqlspec/core/metrics.py +83 -0
- sqlspec/core/parameters/__init__.py +72 -0
- sqlspec/core/parameters/_alignment.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_alignment.py +283 -0
- sqlspec/core/parameters/_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_converter.py +554 -0
- sqlspec/core/parameters/_processor.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_processor.py +1182 -0
- sqlspec/core/parameters/_registry.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_registry.py +206 -0
- sqlspec/core/parameters/_transformers.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_transformers.py +324 -0
- sqlspec/core/parameters/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_types.py +536 -0
- sqlspec/core/parameters/_validator.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_validator.py +171 -0
- sqlspec/core/pipeline.cp314-win_amd64.pyd +0 -0
- sqlspec/core/pipeline.py +333 -0
- sqlspec/core/query_modifiers.cp314-win_amd64.pyd +0 -0
- sqlspec/core/query_modifiers.py +508 -0
- sqlspec/core/result/__init__.py +25 -0
- sqlspec/core/result/_base.cp314-win_amd64.pyd +0 -0
- sqlspec/core/result/_base.py +1232 -0
- sqlspec/core/result/_io.cp314-win_amd64.pyd +0 -0
- sqlspec/core/result/_io.py +28 -0
- sqlspec/core/splitter.cp314-win_amd64.pyd +0 -0
- sqlspec/core/splitter.py +1021 -0
- sqlspec/core/sqlcommenter.cp314-win_amd64.pyd +0 -0
- sqlspec/core/sqlcommenter.py +249 -0
- sqlspec/core/stack.cp314-win_amd64.pyd +0 -0
- sqlspec/core/stack.py +163 -0
- sqlspec/core/statement.cp314-win_amd64.pyd +0 -0
- sqlspec/core/statement.py +1865 -0
- sqlspec/core/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/core/type_converter.py +340 -0
- sqlspec/data_dictionary/__init__.py +22 -0
- sqlspec/data_dictionary/_loader.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_loader.py +138 -0
- sqlspec/data_dictionary/_registry.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_registry.py +74 -0
- sqlspec/data_dictionary/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_types.py +121 -0
- sqlspec/data_dictionary/dialects/__init__.py +21 -0
- sqlspec/data_dictionary/dialects/bigquery.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/bigquery.py +81 -0
- sqlspec/data_dictionary/dialects/cockroachdb.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb.py +54 -0
- sqlspec/data_dictionary/dialects/duckdb.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/duckdb.py +47 -0
- sqlspec/data_dictionary/dialects/mysql.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mysql.py +53 -0
- sqlspec/data_dictionary/dialects/oracle.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/oracle.py +197 -0
- sqlspec/data_dictionary/dialects/postgres.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/postgres.py +69 -0
- sqlspec/data_dictionary/dialects/spanner.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/spanner.py +37 -0
- sqlspec/data_dictionary/dialects/sqlite.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlite.py +59 -0
- sqlspec/data_dictionary/sql/.gitkeep +0 -0
- sqlspec/data_dictionary/sql/bigquery/columns.sql +23 -0
- sqlspec/data_dictionary/sql/bigquery/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/sql/bigquery/indexes.sql +19 -0
- sqlspec/data_dictionary/sql/bigquery/tables.sql +33 -0
- sqlspec/data_dictionary/sql/bigquery/version.sql +3 -0
- sqlspec/data_dictionary/sql/cockroachdb/columns.sql +34 -0
- sqlspec/data_dictionary/sql/cockroachdb/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/sql/cockroachdb/indexes.sql +32 -0
- sqlspec/data_dictionary/sql/cockroachdb/tables.sql +44 -0
- sqlspec/data_dictionary/sql/cockroachdb/version.sql +3 -0
- sqlspec/data_dictionary/sql/duckdb/columns.sql +23 -0
- sqlspec/data_dictionary/sql/duckdb/foreign_keys.sql +36 -0
- sqlspec/data_dictionary/sql/duckdb/indexes.sql +19 -0
- sqlspec/data_dictionary/sql/duckdb/tables.sql +38 -0
- sqlspec/data_dictionary/sql/duckdb/version.sql +3 -0
- sqlspec/data_dictionary/sql/mysql/columns.sql +23 -0
- sqlspec/data_dictionary/sql/mysql/foreign_keys.sql +28 -0
- sqlspec/data_dictionary/sql/mysql/indexes.sql +26 -0
- sqlspec/data_dictionary/sql/mysql/tables.sql +33 -0
- sqlspec/data_dictionary/sql/mysql/version.sql +3 -0
- sqlspec/data_dictionary/sql/oracle/columns.sql +23 -0
- sqlspec/data_dictionary/sql/oracle/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/sql/oracle/indexes.sql +44 -0
- sqlspec/data_dictionary/sql/oracle/tables.sql +25 -0
- sqlspec/data_dictionary/sql/oracle/version.sql +20 -0
- sqlspec/data_dictionary/sql/postgres/columns.sql +34 -0
- sqlspec/data_dictionary/sql/postgres/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/sql/postgres/indexes.sql +56 -0
- sqlspec/data_dictionary/sql/postgres/tables.sql +44 -0
- sqlspec/data_dictionary/sql/postgres/version.sql +3 -0
- sqlspec/data_dictionary/sql/spanner/columns.sql +23 -0
- sqlspec/data_dictionary/sql/spanner/foreign_keys.sql +70 -0
- sqlspec/data_dictionary/sql/spanner/indexes.sql +30 -0
- sqlspec/data_dictionary/sql/spanner/tables.sql +9 -0
- sqlspec/data_dictionary/sql/spanner/version.sql +3 -0
- sqlspec/data_dictionary/sql/sqlite/columns.sql +23 -0
- sqlspec/data_dictionary/sql/sqlite/foreign_keys.sql +22 -0
- sqlspec/data_dictionary/sql/sqlite/indexes.sql +7 -0
- sqlspec/data_dictionary/sql/sqlite/tables.sql +28 -0
- sqlspec/data_dictionary/sql/sqlite/version.sql +3 -0
- sqlspec/dialects/__init__.py +22 -0
- sqlspec/dialects/_compat.cp314-win_amd64.pyd +0 -0
- sqlspec/dialects/_compat.py +14 -0
- sqlspec/dialects/postgres/__init__.py +9 -0
- sqlspec/dialects/postgres/_generators.cp314-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_generators.py +57 -0
- sqlspec/dialects/postgres/_operators.cp314-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_operators.py +81 -0
- sqlspec/dialects/postgres/_paradedb.py +50 -0
- sqlspec/dialects/postgres/_pgvector.py +36 -0
- sqlspec/dialects/spanner/__init__.py +6 -0
- sqlspec/dialects/spanner/_generators.cp314-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_generators.py +206 -0
- sqlspec/dialects/spanner/_spangres.py +77 -0
- sqlspec/dialects/spanner/_spanner.py +179 -0
- sqlspec/driver/__init__.py +49 -0
- sqlspec/driver/_async.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_async.py +1830 -0
- sqlspec/driver/_common.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_common.py +2292 -0
- sqlspec/driver/_exception_handler.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_exception_handler.py +108 -0
- sqlspec/driver/_query_cache.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_query_cache.py +96 -0
- sqlspec/driver/_sql_helpers.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_sql_helpers.py +139 -0
- sqlspec/driver/_storage_helpers.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_storage_helpers.py +153 -0
- sqlspec/driver/_sync.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_sync.py +1817 -0
- sqlspec/exceptions.cp314-win_amd64.pyd +0 -0
- sqlspec/exceptions.py +480 -0
- sqlspec/extensions/__init__.py +0 -0
- sqlspec/extensions/adk/__init__.py +84 -0
- sqlspec/extensions/adk/_config_utils.py +199 -0
- sqlspec/extensions/adk/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_types.py +41 -0
- sqlspec/extensions/adk/artifact/__init__.py +57 -0
- sqlspec/extensions/adk/artifact/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/artifact/_types.py +32 -0
- sqlspec/extensions/adk/artifact/service.py +508 -0
- sqlspec/extensions/adk/artifact/store.py +361 -0
- sqlspec/extensions/adk/converters.py +212 -0
- sqlspec/extensions/adk/memory/__init__.py +69 -0
- sqlspec/extensions/adk/memory/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/memory/_types.py +30 -0
- sqlspec/extensions/adk/memory/converters.py +225 -0
- sqlspec/extensions/adk/memory/service.py +316 -0
- sqlspec/extensions/adk/memory/store.py +525 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +184 -0
- sqlspec/extensions/adk/migrations/__init__.py +0 -0
- sqlspec/extensions/adk/service.py +279 -0
- sqlspec/extensions/adk/store.py +590 -0
- sqlspec/extensions/events/__init__.py +51 -0
- sqlspec/extensions/events/_channel.py +703 -0
- sqlspec/extensions/events/_hints.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_hints.py +45 -0
- sqlspec/extensions/events/_models.py +23 -0
- sqlspec/extensions/events/_payload.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_payload.py +69 -0
- sqlspec/extensions/events/_protocols.py +134 -0
- sqlspec/extensions/events/_queue.py +462 -0
- sqlspec/extensions/events/_store.py +209 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +59 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/fastapi/__init__.py +22 -0
- sqlspec/extensions/fastapi/extension.py +391 -0
- sqlspec/extensions/fastapi/providers.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/fastapi/providers.py +712 -0
- sqlspec/extensions/flask/__init__.py +38 -0
- sqlspec/extensions/flask/_state.py +87 -0
- sqlspec/extensions/flask/_utils.py +71 -0
- sqlspec/extensions/flask/extension.py +539 -0
- sqlspec/extensions/litestar/__init__.py +31 -0
- sqlspec/extensions/litestar/_utils.py +52 -0
- sqlspec/extensions/litestar/channels.py +165 -0
- sqlspec/extensions/litestar/cli.py +102 -0
- sqlspec/extensions/litestar/config.py +90 -0
- sqlspec/extensions/litestar/handlers.py +316 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +137 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/plugin.py +1066 -0
- sqlspec/extensions/litestar/providers.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/providers.py +784 -0
- sqlspec/extensions/litestar/store.py +298 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +113 -0
- sqlspec/extensions/sanic/__init__.py +19 -0
- sqlspec/extensions/sanic/_state.py +43 -0
- sqlspec/extensions/sanic/_utils.py +127 -0
- sqlspec/extensions/sanic/extension.py +647 -0
- sqlspec/extensions/starlette/__init__.py +22 -0
- sqlspec/extensions/starlette/_state.py +42 -0
- sqlspec/extensions/starlette/_utils.py +96 -0
- sqlspec/extensions/starlette/extension.py +374 -0
- sqlspec/extensions/starlette/middleware.py +281 -0
- sqlspec/loader.cp314-win_amd64.pyd +0 -0
- sqlspec/loader.py +727 -0
- sqlspec/migrations/__init__.py +39 -0
- sqlspec/migrations/base.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/base.py +862 -0
- sqlspec/migrations/commands.py +2151 -0
- sqlspec/migrations/context.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/context.py +157 -0
- sqlspec/migrations/fix.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/fix.py +204 -0
- sqlspec/migrations/loaders.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/loaders.py +443 -0
- sqlspec/migrations/runner.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/runner.py +1195 -0
- sqlspec/migrations/squash.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/squash.py +490 -0
- sqlspec/migrations/templates.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/templates.py +234 -0
- sqlspec/migrations/tracker.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/tracker.py +792 -0
- sqlspec/migrations/utils.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/utils.py +256 -0
- sqlspec/migrations/validation.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/validation.py +359 -0
- sqlspec/migrations/version.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/version.py +446 -0
- sqlspec/observability/__init__.py +57 -0
- sqlspec/observability/_common.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_common.py +77 -0
- sqlspec/observability/_config.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_config.py +364 -0
- sqlspec/observability/_diagnostics.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_diagnostics.py +74 -0
- sqlspec/observability/_dispatcher.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_dispatcher.py +200 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_aws.py +102 -0
- sqlspec/observability/_formatters/_azure.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_azure.py +96 -0
- sqlspec/observability/_formatters/_base.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_base.py +57 -0
- sqlspec/observability/_formatters/_gcp.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_gcp.py +131 -0
- sqlspec/observability/_formatting.py +58 -0
- sqlspec/observability/_observer.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_observer.py +361 -0
- sqlspec/observability/_runtime.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_runtime.py +461 -0
- sqlspec/observability/_sampling.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_sampling.py +188 -0
- sqlspec/observability/_spans.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_spans.py +161 -0
- sqlspec/protocols.py +955 -0
- sqlspec/py.typed +0 -0
- sqlspec/service.py +433 -0
- sqlspec/storage/__init__.py +48 -0
- sqlspec/storage/_arrow_payload.py +68 -0
- sqlspec/storage/_paths.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/_paths.py +58 -0
- sqlspec/storage/_utils.py +46 -0
- sqlspec/storage/backends/__init__.py +1 -0
- sqlspec/storage/backends/base.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/backends/base.py +374 -0
- sqlspec/storage/backends/fsspec.py +574 -0
- sqlspec/storage/backends/local.py +468 -0
- sqlspec/storage/backends/obstore.py +956 -0
- sqlspec/storage/errors.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/errors.py +102 -0
- sqlspec/storage/pipeline.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/pipeline.py +628 -0
- sqlspec/storage/registry.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/registry.py +329 -0
- sqlspec/typing.py +405 -0
- sqlspec/utils/__init__.py +7 -0
- sqlspec/utils/arrow_helpers.py +384 -0
- sqlspec/utils/config_tools.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/config_tools.py +314 -0
- sqlspec/utils/correlation.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/correlation.py +134 -0
- sqlspec/utils/deprecation.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/deprecation.py +157 -0
- sqlspec/utils/dispatch.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/dispatch.py +101 -0
- sqlspec/utils/fixtures.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/fixtures.py +260 -0
- sqlspec/utils/logging.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/logging.py +251 -0
- sqlspec/utils/module_loader.py +306 -0
- sqlspec/utils/portal.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/portal.py +377 -0
- sqlspec/utils/schema.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/schema.py +1040 -0
- sqlspec/utils/serializers/__init__.py +30 -0
- sqlspec/utils/serializers/_json.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_json.py +415 -0
- sqlspec/utils/serializers/_numpy.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_numpy.py +65 -0
- sqlspec/utils/serializers/_schema.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_schema.py +285 -0
- sqlspec/utils/singleton.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/singleton.py +41 -0
- sqlspec/utils/sync_tools.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/sync_tools.py +316 -0
- sqlspec/utils/text.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/text.py +109 -0
- sqlspec/utils/type_converters.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/type_converters.py +216 -0
- sqlspec/utils/type_guards.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/type_guards.py +1508 -0
- sqlspec/utils/uuids.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/uuids.py +241 -0
- sqlspec-0.47.0.dist-info/METADATA +202 -0
- sqlspec-0.47.0.dist-info/RECORD +621 -0
- sqlspec-0.47.0.dist-info/WHEEL +4 -0
- sqlspec-0.47.0.dist-info/entry_points.txt +6 -0
- sqlspec-0.47.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
"""AsyncPG database configuration with direct field-based configuration."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any, ClassVar, TypedDict, cast
|
|
4
|
+
|
|
5
|
+
from asyncpg import Connection, Record
|
|
6
|
+
from asyncpg import create_pool as asyncpg_create_pool
|
|
7
|
+
from asyncpg.connection import ConnectionMeta
|
|
8
|
+
from asyncpg.pool import Pool, PoolConnectionProxy, PoolConnectionProxyMeta
|
|
9
|
+
from mypy_extensions import mypyc_attr
|
|
10
|
+
from typing_extensions import NotRequired
|
|
11
|
+
|
|
12
|
+
from sqlspec.adapters.asyncpg._typing import (
|
|
13
|
+
AsyncpgConnection,
|
|
14
|
+
AsyncpgCursor,
|
|
15
|
+
AsyncpgPool,
|
|
16
|
+
AsyncpgPreparedStatement,
|
|
17
|
+
AsyncpgSessionContext,
|
|
18
|
+
)
|
|
19
|
+
from sqlspec.adapters.asyncpg.core import (
|
|
20
|
+
apply_driver_features,
|
|
21
|
+
build_connection_config,
|
|
22
|
+
build_postgres_extension_probe_names,
|
|
23
|
+
default_statement_config,
|
|
24
|
+
register_json_codecs,
|
|
25
|
+
register_pgvector_support,
|
|
26
|
+
resolve_postgres_extension_state,
|
|
27
|
+
resolve_runtime_statement_config,
|
|
28
|
+
)
|
|
29
|
+
from sqlspec.adapters.asyncpg.driver import AsyncpgDriver, AsyncpgExceptionHandler
|
|
30
|
+
from sqlspec.config import AsyncDatabaseConfig, ExtensionConfigs
|
|
31
|
+
from sqlspec.driver._async import AsyncPoolConnectionContext, AsyncPoolSessionFactory
|
|
32
|
+
from sqlspec.exceptions import ImproperConfigurationError, MissingDependencyError
|
|
33
|
+
from sqlspec.extensions.events import EventRuntimeHints
|
|
34
|
+
from sqlspec.typing import ALLOYDB_CONNECTOR_INSTALLED, CLOUD_SQL_CONNECTOR_INSTALLED, PGVECTOR_INSTALLED
|
|
35
|
+
from sqlspec.utils.config_tools import normalize_connection_config
|
|
36
|
+
from sqlspec.utils.logging import get_logger
|
|
37
|
+
from sqlspec.utils.serializers import from_json, to_json
|
|
38
|
+
|
|
39
|
+
if TYPE_CHECKING:
|
|
40
|
+
from asyncio.events import AbstractEventLoop
|
|
41
|
+
from collections.abc import Awaitable, Callable
|
|
42
|
+
|
|
43
|
+
from sqlspec.core import StatementConfig
|
|
44
|
+
from sqlspec.observability import ObservabilityConfig
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
__all__ = (
|
|
48
|
+
"PGVECTOR_INSTALLED",
|
|
49
|
+
"AsyncpgConfig",
|
|
50
|
+
"AsyncpgConnectionConfig",
|
|
51
|
+
"AsyncpgDriverFeatures",
|
|
52
|
+
"AsyncpgPoolConfig",
|
|
53
|
+
"register_json_codecs",
|
|
54
|
+
"register_pgvector_support",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
logger = get_logger(__name__)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class AsyncpgConnectionConfig(TypedDict):
|
|
62
|
+
"""TypedDict for AsyncPG connection parameters."""
|
|
63
|
+
|
|
64
|
+
dsn: NotRequired[str]
|
|
65
|
+
host: NotRequired[str]
|
|
66
|
+
port: NotRequired[int]
|
|
67
|
+
user: NotRequired[str]
|
|
68
|
+
password: NotRequired[str]
|
|
69
|
+
database: NotRequired[str]
|
|
70
|
+
ssl: NotRequired[Any]
|
|
71
|
+
passfile: NotRequired[str]
|
|
72
|
+
direct_tls: NotRequired[bool]
|
|
73
|
+
connect_timeout: NotRequired[float]
|
|
74
|
+
command_timeout: NotRequired[float]
|
|
75
|
+
statement_cache_size: NotRequired[int]
|
|
76
|
+
max_cached_statement_lifetime: NotRequired[int]
|
|
77
|
+
max_cacheable_statement_size: NotRequired[int]
|
|
78
|
+
server_settings: NotRequired["dict[str, str]"]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class AsyncpgPoolConfig(AsyncpgConnectionConfig):
|
|
82
|
+
"""TypedDict for AsyncPG pool parameters, inheriting connection parameters."""
|
|
83
|
+
|
|
84
|
+
min_size: NotRequired[int]
|
|
85
|
+
max_size: NotRequired[int]
|
|
86
|
+
max_queries: NotRequired[int]
|
|
87
|
+
max_inactive_connection_lifetime: NotRequired[float]
|
|
88
|
+
setup: NotRequired["Callable[[AsyncpgConnection], Awaitable[None]]"]
|
|
89
|
+
init: NotRequired["Callable[[AsyncpgConnection], Awaitable[None]]"]
|
|
90
|
+
loop: NotRequired["AbstractEventLoop"]
|
|
91
|
+
connection_class: NotRequired[type["AsyncpgConnection"]]
|
|
92
|
+
record_class: NotRequired[type[Record]]
|
|
93
|
+
extra: NotRequired["dict[str, Any]"]
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AsyncpgDriverFeatures(TypedDict):
|
|
97
|
+
"""AsyncPG driver feature flags.
|
|
98
|
+
|
|
99
|
+
json_serializer: Custom JSON serializer function for PostgreSQL JSON/JSONB types.
|
|
100
|
+
Defaults to sqlspec.utils.serializers.to_json.
|
|
101
|
+
Use for performance optimization (e.g., orjson) or custom encoding behavior.
|
|
102
|
+
Applied when enable_json_codecs is True.
|
|
103
|
+
json_deserializer: Custom JSON deserializer function for PostgreSQL JSON/JSONB types.
|
|
104
|
+
Defaults to sqlspec.utils.serializers.from_json.
|
|
105
|
+
Use for performance optimization (e.g., orjson) or custom decoding behavior.
|
|
106
|
+
Applied when enable_json_codecs is True.
|
|
107
|
+
enable_json_codecs: Enable automatic JSON/JSONB codec registration on connections.
|
|
108
|
+
Defaults to True for seamless Python dict/list to PostgreSQL JSON/JSONB conversion.
|
|
109
|
+
Set to False to disable automatic codec registration (manual handling required).
|
|
110
|
+
enable_pgvector: Enable pgvector extension support for vector similarity search.
|
|
111
|
+
Requires pgvector-python package (pip install pgvector) and PostgreSQL with pgvector extension.
|
|
112
|
+
Defaults to True when pgvector-python is installed.
|
|
113
|
+
Provides automatic conversion between Python objects and PostgreSQL vector types.
|
|
114
|
+
Enables vector similarity operations and index support.
|
|
115
|
+
enable_paradedb: Enable ParadeDB (pg_search) extension detection.
|
|
116
|
+
When enabled and the pg_search extension is detected, the SQL dialect
|
|
117
|
+
switches to "paradedb" which supports search operators (@@@, &&&, etc.)
|
|
118
|
+
and inherits all pgvector distance operators.
|
|
119
|
+
Defaults to True. Independent of enable_pgvector.
|
|
120
|
+
enable_cloud_sql: Enable Google Cloud SQL connector integration.
|
|
121
|
+
Requires cloud-sql-python-connector package.
|
|
122
|
+
Defaults to False (explicit opt-in required).
|
|
123
|
+
Auto-configures IAM authentication, SSL, and IP routing.
|
|
124
|
+
Mutually exclusive with enable_alloydb.
|
|
125
|
+
cloud_sql_instance: Cloud SQL instance connection name.
|
|
126
|
+
Format: "project:region:instance"
|
|
127
|
+
Required when enable_cloud_sql is True.
|
|
128
|
+
cloud_sql_enable_iam_auth: Enable IAM database authentication.
|
|
129
|
+
Defaults to False for passwordless authentication.
|
|
130
|
+
When False, requires user/password in connection_config.
|
|
131
|
+
cloud_sql_ip_type: IP address type for connection.
|
|
132
|
+
Options: "PUBLIC", "PRIVATE", "PSC"
|
|
133
|
+
Defaults to "PRIVATE".
|
|
134
|
+
enable_alloydb: Enable Google AlloyDB connector integration.
|
|
135
|
+
Requires cloud-alloydb-python-connector package.
|
|
136
|
+
Defaults to False (explicit opt-in required).
|
|
137
|
+
Auto-configures IAM authentication and private networking.
|
|
138
|
+
Mutually exclusive with enable_cloud_sql.
|
|
139
|
+
alloydb_instance_uri: AlloyDB instance URI.
|
|
140
|
+
Format: "projects/PROJECT/locations/REGION/clusters/CLUSTER/instances/INSTANCE"
|
|
141
|
+
Required when enable_alloydb is True.
|
|
142
|
+
enable_alloydb_iam_auth: Enable IAM database authentication.
|
|
143
|
+
Defaults to False for passwordless authentication.
|
|
144
|
+
alloydb_ip_type: IP address type for connection.
|
|
145
|
+
Options: "PUBLIC", "PRIVATE", "PSC"
|
|
146
|
+
Defaults to "PRIVATE".
|
|
147
|
+
enable_events: Enable database event channel support.
|
|
148
|
+
Defaults to True when extension_config["events"] is configured.
|
|
149
|
+
Provides pub/sub capabilities via LISTEN/NOTIFY or table-backed fallback.
|
|
150
|
+
Requires extension_config["events"] for migration setup when using table_queue backend.
|
|
151
|
+
events_backend: Event channel backend selection.
|
|
152
|
+
Options: "listen_notify", "table_queue", "listen_notify_durable"
|
|
153
|
+
- "listen_notify": Zero-copy PostgreSQL LISTEN/NOTIFY (ephemeral, real-time)
|
|
154
|
+
- "table_queue": Durable table-backed queue with retries and exactly-once delivery
|
|
155
|
+
- "listen_notify_durable": Hybrid - combines real-time LISTEN/NOTIFY with table durability (recommended for production)
|
|
156
|
+
Defaults to "listen_notify" for backward compatibility.
|
|
157
|
+
Note: "listen_notify_durable" provides best of both worlds - <100ms latency with full durability.
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
json_serializer: NotRequired["Callable[[Any], str]"]
|
|
161
|
+
json_deserializer: NotRequired["Callable[[str], Any]"]
|
|
162
|
+
enable_json_codecs: NotRequired[bool]
|
|
163
|
+
enable_pgvector: NotRequired[bool]
|
|
164
|
+
enable_paradedb: NotRequired[bool]
|
|
165
|
+
enable_cloud_sql: NotRequired[bool]
|
|
166
|
+
cloud_sql_instance: NotRequired[str]
|
|
167
|
+
cloud_sql_enable_iam_auth: NotRequired[bool]
|
|
168
|
+
cloud_sql_ip_type: NotRequired[str]
|
|
169
|
+
enable_alloydb: NotRequired[bool]
|
|
170
|
+
alloydb_instance_uri: NotRequired[str]
|
|
171
|
+
enable_alloydb_iam_auth: NotRequired[bool]
|
|
172
|
+
alloydb_ip_type: NotRequired[str]
|
|
173
|
+
enable_events: NotRequired[bool]
|
|
174
|
+
events_backend: NotRequired[str]
|
|
175
|
+
connection_instance: NotRequired["AsyncpgPool"]
|
|
176
|
+
on_connection_create: NotRequired["Callable[[AsyncpgConnection], Awaitable[None]]"]
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class _AsyncpgCloudSqlConnector:
|
|
180
|
+
__slots__ = ("_config", "_database", "_password", "_user")
|
|
181
|
+
|
|
182
|
+
def __init__(self, config: "AsyncpgConfig", user: str | None, password: str | None, database: str | None) -> None:
|
|
183
|
+
self._config = config
|
|
184
|
+
self._user = user
|
|
185
|
+
self._password = password
|
|
186
|
+
self._database = database
|
|
187
|
+
|
|
188
|
+
async def __call__(self) -> "AsyncpgConnection":
|
|
189
|
+
connector = self._config.get_cloud_sql_connector()
|
|
190
|
+
if connector is None:
|
|
191
|
+
msg = "Cloud SQL connector is not initialized"
|
|
192
|
+
raise ImproperConfigurationError(msg)
|
|
193
|
+
conn_kwargs: dict[str, Any] = {
|
|
194
|
+
"instance_connection_string": self._config.driver_features["cloud_sql_instance"],
|
|
195
|
+
"driver": "asyncpg",
|
|
196
|
+
"enable_iam_auth": self._config.driver_features.get("cloud_sql_enable_iam_auth", False),
|
|
197
|
+
"ip_type": self._config.driver_features.get("cloud_sql_ip_type", "PRIVATE"),
|
|
198
|
+
}
|
|
199
|
+
if self._user:
|
|
200
|
+
conn_kwargs["user"] = self._user
|
|
201
|
+
if self._password:
|
|
202
|
+
conn_kwargs["password"] = self._password
|
|
203
|
+
if self._database:
|
|
204
|
+
conn_kwargs["db"] = self._database
|
|
205
|
+
return cast("AsyncpgConnection", await connector.connect_async(**conn_kwargs))
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class _AsyncpgAlloydbConnector:
|
|
209
|
+
__slots__ = ("_config", "_database", "_password", "_user")
|
|
210
|
+
|
|
211
|
+
def __init__(self, config: "AsyncpgConfig", user: str | None, password: str | None, database: str | None) -> None:
|
|
212
|
+
self._config = config
|
|
213
|
+
self._user = user
|
|
214
|
+
self._password = password
|
|
215
|
+
self._database = database
|
|
216
|
+
|
|
217
|
+
async def __call__(self) -> "AsyncpgConnection":
|
|
218
|
+
connector = self._config.get_alloydb_connector()
|
|
219
|
+
if connector is None:
|
|
220
|
+
msg = "AlloyDB connector is not initialized"
|
|
221
|
+
raise ImproperConfigurationError(msg)
|
|
222
|
+
conn_kwargs: dict[str, Any] = {
|
|
223
|
+
"instance_uri": self._config.driver_features["alloydb_instance_uri"],
|
|
224
|
+
"driver": "asyncpg",
|
|
225
|
+
"enable_iam_auth": self._config.driver_features.get("enable_alloydb_iam_auth", False),
|
|
226
|
+
"ip_type": self._config.driver_features.get("alloydb_ip_type", "PRIVATE"),
|
|
227
|
+
}
|
|
228
|
+
if self._user:
|
|
229
|
+
conn_kwargs["user"] = self._user
|
|
230
|
+
if self._password:
|
|
231
|
+
conn_kwargs["password"] = self._password
|
|
232
|
+
if self._database:
|
|
233
|
+
conn_kwargs["db"] = self._database
|
|
234
|
+
return cast("AsyncpgConnection", await connector.connect(**conn_kwargs))
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class _AsyncpgSessionFactory(AsyncPoolSessionFactory):
|
|
238
|
+
__slots__ = ()
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class AsyncpgConnectionContext(AsyncPoolConnectionContext):
|
|
242
|
+
"""Async context manager for AsyncPG connections."""
|
|
243
|
+
|
|
244
|
+
__slots__ = ()
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
@mypyc_attr(native_class=False)
|
|
248
|
+
class AsyncpgConfig(AsyncDatabaseConfig[AsyncpgConnection, "Pool[Record]", AsyncpgDriver]):
|
|
249
|
+
"""Configuration for AsyncPG database connections using TypedDict.
|
|
250
|
+
|
|
251
|
+
Example::
|
|
252
|
+
|
|
253
|
+
config = AsyncpgConfig(
|
|
254
|
+
connection_config=AsyncpgPoolConfig(
|
|
255
|
+
dsn="postgresql://user:pass@localhost/db"
|
|
256
|
+
)
|
|
257
|
+
)
|
|
258
|
+
"""
|
|
259
|
+
|
|
260
|
+
driver_type: "ClassVar[type[AsyncpgDriver]]" = AsyncpgDriver
|
|
261
|
+
connection_type: "ClassVar[type[AsyncpgConnection]]" = type(AsyncpgConnection) # type: ignore[assignment]
|
|
262
|
+
supports_transactional_ddl: "ClassVar[bool]" = True
|
|
263
|
+
supports_native_arrow_export: "ClassVar[bool]" = True
|
|
264
|
+
supports_native_arrow_import: "ClassVar[bool]" = True
|
|
265
|
+
supports_native_parquet_export: "ClassVar[bool]" = True
|
|
266
|
+
supports_native_parquet_import: "ClassVar[bool]" = True
|
|
267
|
+
_connection_context_class: "ClassVar[type[AsyncpgConnectionContext]]" = AsyncpgConnectionContext
|
|
268
|
+
_session_factory_class: "ClassVar[type[_AsyncpgSessionFactory]]" = _AsyncpgSessionFactory
|
|
269
|
+
_session_context_class: "ClassVar[type[AsyncpgSessionContext]]" = AsyncpgSessionContext
|
|
270
|
+
_default_statement_config = default_statement_config
|
|
271
|
+
|
|
272
|
+
def __init__(
|
|
273
|
+
self,
|
|
274
|
+
*,
|
|
275
|
+
connection_config: "AsyncpgPoolConfig | dict[str, Any] | None" = None,
|
|
276
|
+
connection_instance: "Pool[Record] | None" = None,
|
|
277
|
+
migration_config: "dict[str, Any] | None" = None,
|
|
278
|
+
statement_config: "StatementConfig | None" = None,
|
|
279
|
+
driver_features: "AsyncpgDriverFeatures | dict[str, Any] | None" = None,
|
|
280
|
+
bind_key: "str | None" = None,
|
|
281
|
+
extension_config: "ExtensionConfigs | None" = None,
|
|
282
|
+
observability_config: "ObservabilityConfig | None" = None,
|
|
283
|
+
**kwargs: Any,
|
|
284
|
+
) -> None:
|
|
285
|
+
"""Initialize AsyncPG configuration.
|
|
286
|
+
|
|
287
|
+
Args:
|
|
288
|
+
connection_config: Connection and pool configuration parameters (TypedDict or dict)
|
|
289
|
+
connection_instance: Existing pool instance to use
|
|
290
|
+
migration_config: Migration configuration
|
|
291
|
+
statement_config: Statement configuration override
|
|
292
|
+
driver_features: Driver features configuration (TypedDict or dict)
|
|
293
|
+
bind_key: Optional unique identifier for this configuration
|
|
294
|
+
extension_config: Extension-specific configuration (e.g., Litestar plugin settings)
|
|
295
|
+
observability_config: Adapter-level observability overrides for lifecycle hooks and observers
|
|
296
|
+
**kwargs: Additional keyword arguments
|
|
297
|
+
"""
|
|
298
|
+
statement_config = statement_config or default_statement_config
|
|
299
|
+
statement_config, driver_features = apply_driver_features(statement_config, driver_features)
|
|
300
|
+
|
|
301
|
+
# Extract user connection hook before storing driver_features
|
|
302
|
+
features_dict = dict(driver_features) if driver_features else {}
|
|
303
|
+
self._user_connection_hook: Callable[[AsyncpgConnection], Awaitable[None]] | None = features_dict.pop(
|
|
304
|
+
"on_connection_create", None
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
super().__init__(
|
|
308
|
+
connection_config=normalize_connection_config(connection_config),
|
|
309
|
+
connection_instance=connection_instance,
|
|
310
|
+
migration_config=migration_config,
|
|
311
|
+
statement_config=statement_config,
|
|
312
|
+
driver_features=features_dict,
|
|
313
|
+
bind_key=bind_key,
|
|
314
|
+
extension_config=extension_config,
|
|
315
|
+
observability_config=observability_config,
|
|
316
|
+
**kwargs,
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
self._cloud_sql_connector: Any | None = None
|
|
320
|
+
self._alloydb_connector: Any | None = None
|
|
321
|
+
self._pgvector_available: bool | None = None
|
|
322
|
+
self._paradedb_available: bool | None = None
|
|
323
|
+
|
|
324
|
+
self._validate_connector_config()
|
|
325
|
+
|
|
326
|
+
def get_cloud_sql_connector(self) -> Any | None:
|
|
327
|
+
"""Return the configured Cloud SQL connector instance."""
|
|
328
|
+
return self._cloud_sql_connector
|
|
329
|
+
|
|
330
|
+
def get_alloydb_connector(self) -> Any | None:
|
|
331
|
+
"""Return the configured AlloyDB connector instance."""
|
|
332
|
+
return self._alloydb_connector
|
|
333
|
+
|
|
334
|
+
def _validate_connector_config(self) -> None:
|
|
335
|
+
"""Validate Google Cloud connector configuration.
|
|
336
|
+
|
|
337
|
+
Raises:
|
|
338
|
+
ImproperConfigurationError: If configuration is invalid.
|
|
339
|
+
MissingDependencyError: If required connector packages are not installed.
|
|
340
|
+
"""
|
|
341
|
+
enable_cloud_sql = self.driver_features.get("enable_cloud_sql", False)
|
|
342
|
+
enable_alloydb = self.driver_features.get("enable_alloydb", False)
|
|
343
|
+
|
|
344
|
+
match (enable_cloud_sql, enable_alloydb):
|
|
345
|
+
case (True, True):
|
|
346
|
+
msg = (
|
|
347
|
+
"Cannot enable both Cloud SQL and AlloyDB connectors simultaneously. "
|
|
348
|
+
"Use separate configs for each database."
|
|
349
|
+
)
|
|
350
|
+
raise ImproperConfigurationError(msg)
|
|
351
|
+
case (False, False):
|
|
352
|
+
return
|
|
353
|
+
case (True, False):
|
|
354
|
+
if not CLOUD_SQL_CONNECTOR_INSTALLED:
|
|
355
|
+
raise MissingDependencyError(package="cloud-sql-python-connector", install_package="cloud-sql")
|
|
356
|
+
|
|
357
|
+
instance = self.driver_features.get("cloud_sql_instance")
|
|
358
|
+
if not instance:
|
|
359
|
+
msg = "cloud_sql_instance required when enable_cloud_sql is True. Format: 'project:region:instance'"
|
|
360
|
+
raise ImproperConfigurationError(msg)
|
|
361
|
+
|
|
362
|
+
cloud_sql_instance_parts_expected = 2
|
|
363
|
+
if instance.count(":") != cloud_sql_instance_parts_expected:
|
|
364
|
+
msg = f"Invalid Cloud SQL instance format: {instance}. Expected format: 'project:region:instance'"
|
|
365
|
+
raise ImproperConfigurationError(msg)
|
|
366
|
+
case (False, True):
|
|
367
|
+
if not ALLOYDB_CONNECTOR_INSTALLED:
|
|
368
|
+
raise MissingDependencyError(
|
|
369
|
+
package="google-cloud-alloydb-connector", install_package="google-cloud-alloydb-connector"
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
instance_uri = self.driver_features.get("alloydb_instance_uri")
|
|
373
|
+
if not instance_uri:
|
|
374
|
+
msg = "alloydb_instance_uri required when enable_alloydb is True. Format: 'projects/PROJECT/locations/REGION/clusters/CLUSTER/instances/INSTANCE'"
|
|
375
|
+
raise ImproperConfigurationError(msg)
|
|
376
|
+
|
|
377
|
+
if not instance_uri.startswith("projects/"):
|
|
378
|
+
msg = f"Invalid AlloyDB instance URI format: {instance_uri}. Expected format: 'projects/PROJECT/locations/REGION/clusters/CLUSTER/instances/INSTANCE'"
|
|
379
|
+
raise ImproperConfigurationError(msg)
|
|
380
|
+
|
|
381
|
+
def _setup_cloud_sql_connector(self, config: "dict[str, Any]") -> None:
|
|
382
|
+
"""Setup Cloud SQL connector and configure pool for connection factory pattern.
|
|
383
|
+
|
|
384
|
+
Args:
|
|
385
|
+
config: Pool configuration dictionary to modify in-place.
|
|
386
|
+
"""
|
|
387
|
+
from google.cloud.sql.connector import Connector # type: ignore[import-untyped,unused-ignore]
|
|
388
|
+
|
|
389
|
+
self._cloud_sql_connector = Connector()
|
|
390
|
+
|
|
391
|
+
user = config.get("user")
|
|
392
|
+
password = config.get("password")
|
|
393
|
+
database = config.get("database")
|
|
394
|
+
|
|
395
|
+
for key in ("dsn", "host", "port", "user", "password", "database"):
|
|
396
|
+
config.pop(key, None)
|
|
397
|
+
|
|
398
|
+
config["connect"] = _AsyncpgCloudSqlConnector(self, user, password, database)
|
|
399
|
+
|
|
400
|
+
def _setup_alloydb_connector(self, config: "dict[str, Any]") -> None:
|
|
401
|
+
"""Setup AlloyDB connector and configure pool for connection factory pattern.
|
|
402
|
+
|
|
403
|
+
Args:
|
|
404
|
+
config: Pool configuration dictionary to modify in-place.
|
|
405
|
+
"""
|
|
406
|
+
from google.cloud.alloydb.connector import AsyncConnector # type: ignore[import-untyped,unused-ignore]
|
|
407
|
+
|
|
408
|
+
self._alloydb_connector = AsyncConnector()
|
|
409
|
+
|
|
410
|
+
user = config.get("user")
|
|
411
|
+
password = config.get("password")
|
|
412
|
+
database = config.get("database")
|
|
413
|
+
|
|
414
|
+
for key in ("dsn", "host", "port", "user", "password", "database"):
|
|
415
|
+
config.pop(key, None)
|
|
416
|
+
|
|
417
|
+
config["connect"] = _AsyncpgAlloydbConnector(self, user, password, database)
|
|
418
|
+
|
|
419
|
+
async def _create_pool(self) -> "Pool[Record]":
|
|
420
|
+
"""Create the actual async connection pool."""
|
|
421
|
+
config = build_connection_config(self.connection_config)
|
|
422
|
+
|
|
423
|
+
if self.driver_features.get("enable_cloud_sql", False):
|
|
424
|
+
self._setup_cloud_sql_connector(config)
|
|
425
|
+
elif self.driver_features.get("enable_alloydb", False):
|
|
426
|
+
self._setup_alloydb_connector(config)
|
|
427
|
+
|
|
428
|
+
config.setdefault("init", self._init_connection)
|
|
429
|
+
|
|
430
|
+
return await asyncpg_create_pool(**config)
|
|
431
|
+
|
|
432
|
+
async def _init_connection(self, connection: "AsyncpgConnection") -> None:
|
|
433
|
+
"""Initialize connection with JSON codecs, pgvector support, and user callback.
|
|
434
|
+
|
|
435
|
+
Args:
|
|
436
|
+
connection: AsyncPG connection to initialize.
|
|
437
|
+
"""
|
|
438
|
+
if self.driver_features.get("enable_json_codecs", True):
|
|
439
|
+
await register_json_codecs(
|
|
440
|
+
connection,
|
|
441
|
+
encoder=self.driver_features.get("json_serializer", to_json),
|
|
442
|
+
decoder=self.driver_features.get("json_deserializer", from_json),
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
# Detect extensions on first connection, update dialect
|
|
446
|
+
if self._pgvector_available is None:
|
|
447
|
+
detected_extensions: set[str] = set()
|
|
448
|
+
extensions = build_postgres_extension_probe_names(self.driver_features)
|
|
449
|
+
if extensions:
|
|
450
|
+
try:
|
|
451
|
+
results = await connection.fetch(
|
|
452
|
+
"SELECT extname FROM pg_extension WHERE extname = ANY($1::text[])", extensions
|
|
453
|
+
)
|
|
454
|
+
detected_extensions = {r["extname"] for r in results}
|
|
455
|
+
except Exception:
|
|
456
|
+
detected_extensions = set()
|
|
457
|
+
self.statement_config, self._pgvector_available, self._paradedb_available = (
|
|
458
|
+
resolve_postgres_extension_state(self.statement_config, self.driver_features, detected_extensions)
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
if self._pgvector_available:
|
|
462
|
+
await register_pgvector_support(connection)
|
|
463
|
+
|
|
464
|
+
# Call user-provided callback after internal setup
|
|
465
|
+
if self._user_connection_hook is not None:
|
|
466
|
+
await self._user_connection_hook(connection)
|
|
467
|
+
|
|
468
|
+
def _update_dialect_for_extensions(self) -> None:
|
|
469
|
+
"""Update statement_config dialect based on detected extensions.
|
|
470
|
+
|
|
471
|
+
Priority: paradedb > pgvector > postgres (default).
|
|
472
|
+
"""
|
|
473
|
+
current_dialect = getattr(self.statement_config, "dialect", "postgres")
|
|
474
|
+
if current_dialect != "postgres":
|
|
475
|
+
return
|
|
476
|
+
|
|
477
|
+
if self._paradedb_available:
|
|
478
|
+
self.statement_config = self.statement_config.replace(dialect="paradedb")
|
|
479
|
+
elif self._pgvector_available:
|
|
480
|
+
self.statement_config = self.statement_config.replace(dialect="pgvector")
|
|
481
|
+
|
|
482
|
+
async def _close_pool(self) -> None:
|
|
483
|
+
"""Close the actual async connection pool and cleanup connectors."""
|
|
484
|
+
if self.connection_instance:
|
|
485
|
+
await self.connection_instance.close()
|
|
486
|
+
self.connection_instance = None
|
|
487
|
+
|
|
488
|
+
if self._cloud_sql_connector is not None:
|
|
489
|
+
await self._cloud_sql_connector.close_async()
|
|
490
|
+
self._cloud_sql_connector = None
|
|
491
|
+
|
|
492
|
+
if self._alloydb_connector is not None:
|
|
493
|
+
await self._alloydb_connector.close()
|
|
494
|
+
self._alloydb_connector = None
|
|
495
|
+
|
|
496
|
+
async def create_connection(self) -> "AsyncpgConnection":
|
|
497
|
+
"""Create a single async connection from the pool.
|
|
498
|
+
|
|
499
|
+
Returns:
|
|
500
|
+
An AsyncPG connection instance.
|
|
501
|
+
"""
|
|
502
|
+
pool = self.connection_instance
|
|
503
|
+
if pool is None:
|
|
504
|
+
pool = await self.create_pool()
|
|
505
|
+
self.connection_instance = pool
|
|
506
|
+
return await pool.acquire()
|
|
507
|
+
|
|
508
|
+
def provide_session(
|
|
509
|
+
self, *_args: Any, statement_config: "StatementConfig | None" = None, **_kwargs: Any
|
|
510
|
+
) -> "AsyncpgSessionContext":
|
|
511
|
+
"""Provide an async driver session context manager.
|
|
512
|
+
|
|
513
|
+
Args:
|
|
514
|
+
*_args: Additional arguments.
|
|
515
|
+
statement_config: Optional statement configuration override.
|
|
516
|
+
**_kwargs: Additional keyword arguments.
|
|
517
|
+
|
|
518
|
+
Returns:
|
|
519
|
+
An AsyncPG driver session context manager.
|
|
520
|
+
"""
|
|
521
|
+
factory = _AsyncpgSessionFactory(self)
|
|
522
|
+
return AsyncpgSessionContext(
|
|
523
|
+
acquire_connection=factory.acquire_connection,
|
|
524
|
+
release_connection=factory.release_connection,
|
|
525
|
+
statement_config=statement_config
|
|
526
|
+
or (lambda: resolve_runtime_statement_config(None, self.statement_config, default_statement_config)),
|
|
527
|
+
driver_features=self.driver_features,
|
|
528
|
+
prepare_driver=self._prepare_driver,
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
async def provide_pool(self, *args: Any, **kwargs: Any) -> "Pool[Record]":
|
|
532
|
+
"""Provide async pool instance.
|
|
533
|
+
|
|
534
|
+
Returns:
|
|
535
|
+
The async connection pool.
|
|
536
|
+
"""
|
|
537
|
+
if not self.connection_instance:
|
|
538
|
+
self.connection_instance = await self.create_pool()
|
|
539
|
+
return self.connection_instance
|
|
540
|
+
|
|
541
|
+
def get_signature_namespace(self) -> "dict[str, Any]":
|
|
542
|
+
"""Get the signature namespace for AsyncPG types.
|
|
543
|
+
|
|
544
|
+
This provides all AsyncPG-specific types that Litestar needs to recognize
|
|
545
|
+
to avoid serialization attempts.
|
|
546
|
+
|
|
547
|
+
Returns:
|
|
548
|
+
Dictionary mapping type names to types.
|
|
549
|
+
"""
|
|
550
|
+
|
|
551
|
+
namespace = super().get_signature_namespace()
|
|
552
|
+
namespace.update({
|
|
553
|
+
"Connection": Connection,
|
|
554
|
+
"Pool": Pool,
|
|
555
|
+
"PoolConnectionProxy": PoolConnectionProxy,
|
|
556
|
+
"PoolConnectionProxyMeta": PoolConnectionProxyMeta,
|
|
557
|
+
"ConnectionMeta": ConnectionMeta,
|
|
558
|
+
"Record": Record,
|
|
559
|
+
"AsyncpgConnection": AsyncpgConnection,
|
|
560
|
+
"AsyncpgConnectionConfig": AsyncpgConnectionConfig,
|
|
561
|
+
"AsyncpgConnectionContext": AsyncpgConnectionContext,
|
|
562
|
+
"AsyncpgCursor": AsyncpgCursor,
|
|
563
|
+
"AsyncpgDriver": AsyncpgDriver,
|
|
564
|
+
"AsyncpgExceptionHandler": AsyncpgExceptionHandler,
|
|
565
|
+
"AsyncpgPool": AsyncpgPool,
|
|
566
|
+
"AsyncpgPoolConfig": AsyncpgPoolConfig,
|
|
567
|
+
"AsyncpgPreparedStatement": AsyncpgPreparedStatement,
|
|
568
|
+
"AsyncpgSessionContext": AsyncpgSessionContext,
|
|
569
|
+
})
|
|
570
|
+
return namespace
|
|
571
|
+
|
|
572
|
+
def get_event_runtime_hints(self) -> "EventRuntimeHints":
|
|
573
|
+
"""Return polling defaults for PostgreSQL queue fallback."""
|
|
574
|
+
|
|
575
|
+
return EventRuntimeHints(poll_interval=0.5, select_for_update=True, skip_locked=True)
|
|
Binary file
|