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,922 @@
|
|
|
1
|
+
"""ADBC adapter compiled helpers."""
|
|
2
|
+
|
|
3
|
+
import datetime
|
|
4
|
+
import decimal
|
|
5
|
+
from collections.abc import Sized
|
|
6
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
7
|
+
|
|
8
|
+
from sqlspec.adapters.adbc.type_converter import get_adbc_type_converter
|
|
9
|
+
from sqlspec.core import (
|
|
10
|
+
DriverParameterProfile,
|
|
11
|
+
ParameterStyle,
|
|
12
|
+
StatementConfig,
|
|
13
|
+
build_null_pruning_transform,
|
|
14
|
+
build_statement_config_from_profile,
|
|
15
|
+
)
|
|
16
|
+
from sqlspec.core.config_runtime import (
|
|
17
|
+
build_postgres_extension_probe_names,
|
|
18
|
+
resolve_postgres_extension_state,
|
|
19
|
+
resolve_runtime_statement_config,
|
|
20
|
+
)
|
|
21
|
+
from sqlspec.exceptions import (
|
|
22
|
+
CheckViolationError,
|
|
23
|
+
DatabaseConnectionError,
|
|
24
|
+
DeadlockError,
|
|
25
|
+
ForeignKeyViolationError,
|
|
26
|
+
ImproperConfigurationError,
|
|
27
|
+
IntegrityError,
|
|
28
|
+
NotNullViolationError,
|
|
29
|
+
PermissionDeniedError,
|
|
30
|
+
QueryTimeoutError,
|
|
31
|
+
SQLParsingError,
|
|
32
|
+
SQLSpecError,
|
|
33
|
+
UniqueViolationError,
|
|
34
|
+
map_sqlstate_to_exception,
|
|
35
|
+
)
|
|
36
|
+
from sqlspec.typing import PGVECTOR_INSTALLED, Empty
|
|
37
|
+
from sqlspec.utils.dispatch import TypeDispatcher
|
|
38
|
+
from sqlspec.utils.module_loader import import_string
|
|
39
|
+
from sqlspec.utils.serializers import to_json
|
|
40
|
+
from sqlspec.utils.type_converters import build_uuid_coercions
|
|
41
|
+
from sqlspec.utils.type_guards import has_rowcount, has_sqlstate
|
|
42
|
+
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from collections.abc import Callable, Mapping
|
|
45
|
+
|
|
46
|
+
from sqlspec.core import SQL
|
|
47
|
+
|
|
48
|
+
__all__ = (
|
|
49
|
+
"apply_driver_features",
|
|
50
|
+
"build_connection_config",
|
|
51
|
+
"build_postgres_extension_probe_names",
|
|
52
|
+
"build_profile",
|
|
53
|
+
"collect_rows",
|
|
54
|
+
"create_mapped_exception",
|
|
55
|
+
"detect_dialect",
|
|
56
|
+
"detect_postgres_extensions",
|
|
57
|
+
"driver_from_uri",
|
|
58
|
+
"driver_kind_from_driver_name",
|
|
59
|
+
"driver_kind_from_uri",
|
|
60
|
+
"driver_profile",
|
|
61
|
+
"get_statement_config",
|
|
62
|
+
"handle_postgres_rollback",
|
|
63
|
+
"is_postgres_dialect",
|
|
64
|
+
"normalize_driver_path",
|
|
65
|
+
"normalize_postgres_empty_parameters",
|
|
66
|
+
"normalize_script_rowcount",
|
|
67
|
+
"prepare_parameters_with_casts",
|
|
68
|
+
"prepare_postgres_parameters",
|
|
69
|
+
"resolve_column_names",
|
|
70
|
+
"resolve_dialect_from_config",
|
|
71
|
+
"resolve_dialect_from_driver_path",
|
|
72
|
+
"resolve_dialect_name",
|
|
73
|
+
"resolve_driver_connect_func",
|
|
74
|
+
"resolve_driver_name",
|
|
75
|
+
"resolve_driver_name_from_config",
|
|
76
|
+
"resolve_many_rowcount",
|
|
77
|
+
"resolve_parameter_casts",
|
|
78
|
+
"resolve_parameter_styles",
|
|
79
|
+
"resolve_postgres_extension_state",
|
|
80
|
+
"resolve_rowcount",
|
|
81
|
+
"resolve_runtime_statement_config",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
COLUMN_CACHE_MAX_SIZE: int = 256
|
|
85
|
+
|
|
86
|
+
DIALECT_PATTERNS: "dict[str, tuple[str, ...]]" = {
|
|
87
|
+
"postgres": ("postgres", "postgresql"),
|
|
88
|
+
"bigquery": ("bigquery",),
|
|
89
|
+
"sqlite": ("sqlite", "flight", "flightsql"),
|
|
90
|
+
"duckdb": ("duckdb", "gizmosql", "gizmo"),
|
|
91
|
+
"mysql": ("mysql",),
|
|
92
|
+
"snowflake": ("snowflake",),
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
DIALECT_PARAMETER_STYLES: "dict[str, tuple[ParameterStyle, list[ParameterStyle]]]" = {
|
|
97
|
+
"postgres": (ParameterStyle.NUMERIC, [ParameterStyle.NUMERIC]),
|
|
98
|
+
"postgresql": (ParameterStyle.NUMERIC, [ParameterStyle.NUMERIC]),
|
|
99
|
+
"bigquery": (ParameterStyle.NAMED_AT, [ParameterStyle.NAMED_AT]),
|
|
100
|
+
"sqlite": (ParameterStyle.QMARK, [ParameterStyle.QMARK]),
|
|
101
|
+
"duckdb": (ParameterStyle.QMARK, [ParameterStyle.QMARK, ParameterStyle.NUMERIC, ParameterStyle.NAMED_DOLLAR]),
|
|
102
|
+
"mysql": (ParameterStyle.POSITIONAL_PYFORMAT, [ParameterStyle.POSITIONAL_PYFORMAT, ParameterStyle.NAMED_PYFORMAT]),
|
|
103
|
+
"snowflake": (ParameterStyle.QMARK, [ParameterStyle.QMARK, ParameterStyle.NUMERIC]),
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
_DRIVER_ALIASES: "dict[str, str]" = {
|
|
107
|
+
"sqlite": "adbc_driver_sqlite.dbapi.connect",
|
|
108
|
+
"sqlite3": "adbc_driver_sqlite.dbapi.connect",
|
|
109
|
+
"duckdb": "adbc_driver_duckdb.dbapi.connect",
|
|
110
|
+
"postgres": "adbc_driver_postgresql.dbapi.connect",
|
|
111
|
+
"postgresql": "adbc_driver_postgresql.dbapi.connect",
|
|
112
|
+
"pg": "adbc_driver_postgresql.dbapi.connect",
|
|
113
|
+
"snowflake": "adbc_driver_snowflake.dbapi.connect",
|
|
114
|
+
"sf": "adbc_driver_snowflake.dbapi.connect",
|
|
115
|
+
"bigquery": "adbc_driver_bigquery.dbapi.connect",
|
|
116
|
+
"bq": "adbc_driver_bigquery.dbapi.connect",
|
|
117
|
+
"flightsql": "adbc_driver_flightsql.dbapi.connect",
|
|
118
|
+
"grpc": "adbc_driver_flightsql.dbapi.connect",
|
|
119
|
+
"gizmosql": "adbc_driver_flightsql.dbapi.connect",
|
|
120
|
+
"gizmo": "adbc_driver_flightsql.dbapi.connect",
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
_URI_PREFIX_DRIVER: "tuple[tuple[str, str], ...]" = (
|
|
124
|
+
("postgresql://", "adbc_driver_postgresql.dbapi.connect"),
|
|
125
|
+
("postgres://", "adbc_driver_postgresql.dbapi.connect"),
|
|
126
|
+
("sqlite://", "adbc_driver_sqlite.dbapi.connect"),
|
|
127
|
+
("duckdb://", "adbc_driver_duckdb.dbapi.connect"),
|
|
128
|
+
("grpc://", "adbc_driver_flightsql.dbapi.connect"),
|
|
129
|
+
("grpc+tls://", "adbc_driver_flightsql.dbapi.connect"),
|
|
130
|
+
("gizmosql://", "adbc_driver_flightsql.dbapi.connect"),
|
|
131
|
+
("gizmo://", "adbc_driver_flightsql.dbapi.connect"),
|
|
132
|
+
("snowflake://", "adbc_driver_snowflake.dbapi.connect"),
|
|
133
|
+
("bigquery://", "adbc_driver_bigquery.dbapi.connect"),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
_DRIVER_PATH_KEYWORDS_TO_DIALECT: "tuple[tuple[str, str], ...]" = (
|
|
137
|
+
("postgresql", "postgres"),
|
|
138
|
+
("sqlite", "sqlite"),
|
|
139
|
+
("duckdb", "duckdb"),
|
|
140
|
+
("bigquery", "bigquery"),
|
|
141
|
+
("snowflake", "snowflake"),
|
|
142
|
+
("gizmosql", "duckdb"),
|
|
143
|
+
("flightsql", "sqlite"),
|
|
144
|
+
("grpc", "sqlite"),
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
_PARAMETER_STYLES_BY_KEYWORD: "tuple[tuple[str, tuple[tuple[str, ...], str]], ...]" = (
|
|
148
|
+
("postgresql", (("numeric",), "numeric")),
|
|
149
|
+
("sqlite", (("qmark", "named_colon"), "qmark")),
|
|
150
|
+
("duckdb", (("qmark", "numeric"), "qmark")),
|
|
151
|
+
("gizmosql", (("qmark", "numeric"), "qmark")),
|
|
152
|
+
("bigquery", (("named_at",), "named_at")),
|
|
153
|
+
("snowflake", (("qmark", "numeric"), "qmark")),
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
_BIGQUERY_DB_KWARGS_FIELDS: "tuple[str, ...]" = ("project_id", "dataset_id", "token")
|
|
157
|
+
_TYPE_COERCION_DISPATCHERS: "dict[tuple[tuple[type, Callable[[Any], Any]], ...], TypeDispatcher[Callable[[Any], Any]]]" = {}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def detect_dialect(connection: Any, logger: Any | None = None) -> str:
|
|
161
|
+
"""Detect database dialect from ADBC driver information.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
connection: ADBC connection with driver metadata.
|
|
165
|
+
logger: Optional logger for diagnostics.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
Detected dialect name, defaulting to ``postgres``.
|
|
169
|
+
"""
|
|
170
|
+
try:
|
|
171
|
+
driver_info = connection.adbc_get_info()
|
|
172
|
+
vendor_name = driver_info.get("vendor_name", "").lower()
|
|
173
|
+
driver_name = driver_info.get("driver_name", "").lower()
|
|
174
|
+
|
|
175
|
+
for dialect, patterns in DIALECT_PATTERNS.items():
|
|
176
|
+
for pattern in patterns:
|
|
177
|
+
if pattern in vendor_name or pattern in driver_name:
|
|
178
|
+
if logger is not None:
|
|
179
|
+
logger.debug("Dialect detected: %s (from %s/%s)", dialect, vendor_name, driver_name)
|
|
180
|
+
return dialect
|
|
181
|
+
except Exception as exc:
|
|
182
|
+
if logger is not None:
|
|
183
|
+
logger.debug("Dialect detection failed: %s", exc)
|
|
184
|
+
|
|
185
|
+
if logger is not None:
|
|
186
|
+
logger.warning("Could not determine dialect from driver info. Defaulting to 'postgres'.")
|
|
187
|
+
return "postgres"
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def detect_postgres_extensions(
|
|
191
|
+
connection: Any, *, enable_pgvector: bool = False, enable_paradedb: bool = False
|
|
192
|
+
) -> "tuple[bool, bool]":
|
|
193
|
+
"""Detect pgvector and paradedb extensions on a postgres connection.
|
|
194
|
+
|
|
195
|
+
Queries ``pg_extension`` for the ``vector`` and ``pg_search`` extensions.
|
|
196
|
+
Returns cached-friendly booleans suitable for storing on the config instance.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
connection: ADBC connection to a PostgreSQL database.
|
|
200
|
+
enable_pgvector: Whether to check for the pgvector extension.
|
|
201
|
+
enable_paradedb: Whether to check for the pg_search extension.
|
|
202
|
+
|
|
203
|
+
Returns:
|
|
204
|
+
Tuple of ``(pgvector_available, paradedb_available)``.
|
|
205
|
+
"""
|
|
206
|
+
extensions: list[str] = []
|
|
207
|
+
if enable_pgvector:
|
|
208
|
+
extensions.append("vector")
|
|
209
|
+
if enable_paradedb:
|
|
210
|
+
extensions.append("pg_search")
|
|
211
|
+
|
|
212
|
+
if not extensions:
|
|
213
|
+
return False, False
|
|
214
|
+
|
|
215
|
+
try:
|
|
216
|
+
cursor = connection.cursor()
|
|
217
|
+
try:
|
|
218
|
+
cursor.execute("SELECT extname FROM pg_extension WHERE extname = ANY($1::text[])", [extensions])
|
|
219
|
+
rows = cursor.fetchall()
|
|
220
|
+
detected: set[str] = {row[0] for row in rows} if rows else set()
|
|
221
|
+
return "vector" in detected, "pg_search" in detected
|
|
222
|
+
finally:
|
|
223
|
+
cursor.close()
|
|
224
|
+
except Exception:
|
|
225
|
+
return False, False
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def normalize_driver_path(driver_name: str) -> str:
|
|
229
|
+
"""Normalize a driver name to an importable connect function path."""
|
|
230
|
+
stripped = driver_name.strip()
|
|
231
|
+
if stripped.endswith(".dbapi.connect"):
|
|
232
|
+
return stripped
|
|
233
|
+
if stripped.endswith(".dbapi"):
|
|
234
|
+
return f"{stripped}.connect"
|
|
235
|
+
if "." in stripped:
|
|
236
|
+
return stripped
|
|
237
|
+
return f"{stripped}.dbapi.connect"
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def driver_from_uri(uri: str) -> "str | None":
|
|
241
|
+
"""Resolve a default driver connect path from a URI."""
|
|
242
|
+
for prefix, driver_path in _URI_PREFIX_DRIVER:
|
|
243
|
+
if uri.startswith(prefix):
|
|
244
|
+
return driver_path
|
|
245
|
+
return None
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def driver_kind_from_driver_name(driver_name: str) -> "str | None":
|
|
249
|
+
"""Return a canonical driver kind based on driver name content."""
|
|
250
|
+
lowered_name = driver_name.lower()
|
|
251
|
+
if lowered_name in {"gizmosql", "gizmo"}:
|
|
252
|
+
return "gizmosql"
|
|
253
|
+
resolved = _DRIVER_ALIASES.get(driver_name.lower(), driver_name)
|
|
254
|
+
lowered = resolved.lower()
|
|
255
|
+
for keyword, _dialect in _DRIVER_PATH_KEYWORDS_TO_DIALECT:
|
|
256
|
+
if keyword in lowered:
|
|
257
|
+
return keyword
|
|
258
|
+
return None
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def driver_kind_from_uri(uri: str) -> "str | None":
|
|
262
|
+
"""Return a canonical driver kind based on URI scheme."""
|
|
263
|
+
lowered = uri.lower()
|
|
264
|
+
if lowered.startswith(("gizmosql://", "gizmo://", "grpc+tls://")):
|
|
265
|
+
return "gizmosql"
|
|
266
|
+
for prefix, driver_path in _URI_PREFIX_DRIVER:
|
|
267
|
+
if uri.startswith(prefix):
|
|
268
|
+
return driver_kind_from_driver_name(driver_path)
|
|
269
|
+
return None
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def resolve_driver_name(driver_name: str | None, uri: str | None) -> str:
|
|
273
|
+
"""Resolve and normalize the driver name."""
|
|
274
|
+
if isinstance(driver_name, str):
|
|
275
|
+
lowered_driver = driver_name.lower()
|
|
276
|
+
alias = _DRIVER_ALIASES.get(lowered_driver)
|
|
277
|
+
if alias is not None:
|
|
278
|
+
return alias
|
|
279
|
+
return normalize_driver_path(driver_name)
|
|
280
|
+
|
|
281
|
+
if isinstance(uri, str):
|
|
282
|
+
resolved = driver_from_uri(uri)
|
|
283
|
+
if resolved is not None:
|
|
284
|
+
return resolved
|
|
285
|
+
|
|
286
|
+
return "adbc_driver_sqlite.dbapi.connect"
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def resolve_driver_name_from_config(connection_config: "Mapping[str, Any]") -> str:
|
|
290
|
+
"""Resolve and normalize the driver name from a connection config mapping."""
|
|
291
|
+
return resolve_driver_name(connection_config.get("driver_name"), connection_config.get("uri"))
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def resolve_driver_connect_func(driver_name: str | None, uri: str | None) -> "Callable[..., Any]":
|
|
295
|
+
"""Resolve the driver connect function.
|
|
296
|
+
|
|
297
|
+
Raises:
|
|
298
|
+
ImproperConfigurationError: If driver cannot be loaded.
|
|
299
|
+
"""
|
|
300
|
+
driver_path = resolve_driver_name(driver_name, uri)
|
|
301
|
+
try:
|
|
302
|
+
connect_func = import_string(driver_path)
|
|
303
|
+
except ImportError as exc:
|
|
304
|
+
msg = f"Failed to import connect function from '{driver_path}'. Is the driver installed? Error: {exc}"
|
|
305
|
+
raise ImproperConfigurationError(msg) from exc
|
|
306
|
+
|
|
307
|
+
if not callable(connect_func):
|
|
308
|
+
msg = f"The path '{driver_path}' did not resolve to a callable function."
|
|
309
|
+
raise ImproperConfigurationError(msg)
|
|
310
|
+
|
|
311
|
+
return cast("Callable[..., Any]", connect_func)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def resolve_dialect_from_driver_path(driver_path: str) -> str:
|
|
315
|
+
"""Get the SQL dialect type based on the driver path."""
|
|
316
|
+
for keyword, dialect in _DRIVER_PATH_KEYWORDS_TO_DIALECT:
|
|
317
|
+
if keyword in driver_path:
|
|
318
|
+
return dialect
|
|
319
|
+
return "sqlite"
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def resolve_dialect_from_config(connection_config: "Mapping[str, Any]") -> str:
|
|
323
|
+
"""Resolve dialect using ADBC connection configuration.
|
|
324
|
+
|
|
325
|
+
GizmoSQL connections default to DuckDB unless the backend is explicitly overridden.
|
|
326
|
+
"""
|
|
327
|
+
backend = connection_config.get("gizmosql_backend")
|
|
328
|
+
if isinstance(backend, str):
|
|
329
|
+
lowered_backend = backend.lower()
|
|
330
|
+
if lowered_backend in {"duckdb", "sqlite"}:
|
|
331
|
+
return lowered_backend
|
|
332
|
+
|
|
333
|
+
driver_name = connection_config.get("driver_name")
|
|
334
|
+
if isinstance(driver_name, str) and driver_name.lower() in {"gizmosql", "gizmo"}:
|
|
335
|
+
return "duckdb"
|
|
336
|
+
|
|
337
|
+
uri = connection_config.get("uri")
|
|
338
|
+
if isinstance(uri, str):
|
|
339
|
+
lowered_uri = uri.lower()
|
|
340
|
+
if lowered_uri.startswith(("gizmosql://", "gizmo://", "grpc+tls://")):
|
|
341
|
+
return "duckdb"
|
|
342
|
+
|
|
343
|
+
return resolve_dialect_from_driver_path(resolve_driver_name_from_config(connection_config))
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def resolve_parameter_styles(driver_path: str | None, logger: Any | None = None) -> "tuple[tuple[str, ...], str]":
|
|
347
|
+
"""Resolve supported and default parameter styles from a driver path.
|
|
348
|
+
|
|
349
|
+
Args:
|
|
350
|
+
driver_path: Import path for the ADBC driver connect function.
|
|
351
|
+
logger: Optional logger for diagnostics.
|
|
352
|
+
|
|
353
|
+
Returns:
|
|
354
|
+
Tuple of (supported_parameter_styles, default_parameter_style)
|
|
355
|
+
"""
|
|
356
|
+
if isinstance(driver_path, str):
|
|
357
|
+
lowered = driver_path.lower()
|
|
358
|
+
for keyword, styles in _PARAMETER_STYLES_BY_KEYWORD:
|
|
359
|
+
if keyword in lowered:
|
|
360
|
+
return styles
|
|
361
|
+
if logger is not None:
|
|
362
|
+
logger.debug("Error resolving parameter styles, using defaults")
|
|
363
|
+
return (("qmark",), "qmark")
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def build_connection_config(connection_config: "Mapping[str, Any]") -> "dict[str, Any]":
|
|
367
|
+
"""Build a normalized connection configuration dictionary.
|
|
368
|
+
|
|
369
|
+
Args:
|
|
370
|
+
connection_config: Raw connection configuration mapping.
|
|
371
|
+
|
|
372
|
+
Returns:
|
|
373
|
+
Normalized connection configuration dictionary.
|
|
374
|
+
"""
|
|
375
|
+
config = dict(connection_config)
|
|
376
|
+
|
|
377
|
+
driver_name = config.get("driver_name")
|
|
378
|
+
uri = config.get("uri")
|
|
379
|
+
driver_kind: str | None = None
|
|
380
|
+
if isinstance(driver_name, str):
|
|
381
|
+
driver_kind = driver_kind_from_driver_name(driver_name)
|
|
382
|
+
if driver_kind is None and isinstance(uri, str):
|
|
383
|
+
driver_kind = driver_kind_from_uri(uri)
|
|
384
|
+
|
|
385
|
+
if isinstance(uri, str) and driver_kind == "sqlite" and uri.startswith("sqlite://"):
|
|
386
|
+
config["uri"] = uri[9:]
|
|
387
|
+
if isinstance(uri, str) and driver_kind == "duckdb" and uri.startswith("duckdb://"):
|
|
388
|
+
config["path"] = uri[9:]
|
|
389
|
+
config.pop("uri", None)
|
|
390
|
+
|
|
391
|
+
if isinstance(driver_name, str) and driver_kind == "bigquery":
|
|
392
|
+
db_kwargs = config.get("db_kwargs")
|
|
393
|
+
db_kwargs_dict: dict[str, Any] = dict(db_kwargs) if isinstance(db_kwargs, dict) else {}
|
|
394
|
+
for param in _BIGQUERY_DB_KWARGS_FIELDS:
|
|
395
|
+
if param in config:
|
|
396
|
+
db_kwargs_dict[param] = config.pop(param)
|
|
397
|
+
if db_kwargs_dict:
|
|
398
|
+
config["db_kwargs"] = db_kwargs_dict
|
|
399
|
+
elif isinstance(driver_name, str) and "db_kwargs" in config and driver_kind != "bigquery":
|
|
400
|
+
db_kwargs = config.pop("db_kwargs")
|
|
401
|
+
if isinstance(db_kwargs, dict):
|
|
402
|
+
config.update(db_kwargs)
|
|
403
|
+
|
|
404
|
+
config.pop("driver_name", None)
|
|
405
|
+
|
|
406
|
+
return config
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
def resolve_dialect_name(dialect: Any) -> str:
|
|
410
|
+
"""Return the normalized dialect name string."""
|
|
411
|
+
if dialect is None:
|
|
412
|
+
return ""
|
|
413
|
+
return str(dialect)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def is_postgres_dialect(dialect_name: str) -> bool:
|
|
417
|
+
"""Return True when the dialect indicates PostgreSQL.
|
|
418
|
+
|
|
419
|
+
Includes pgvector and paradedb which are PostgreSQL extension dialects.
|
|
420
|
+
"""
|
|
421
|
+
return dialect_name in {"postgres", "postgresql", "pgvector", "paradedb"}
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def handle_postgres_rollback(dialect: str, cursor: Any, logger: Any | None = None) -> None:
|
|
425
|
+
"""Execute rollback for PostgreSQL after transaction failure.
|
|
426
|
+
|
|
427
|
+
Args:
|
|
428
|
+
dialect: Active dialect identifier.
|
|
429
|
+
cursor: Database cursor to execute rollback.
|
|
430
|
+
logger: Optional logger for diagnostics.
|
|
431
|
+
"""
|
|
432
|
+
if dialect != "postgres":
|
|
433
|
+
return
|
|
434
|
+
try:
|
|
435
|
+
cursor.execute("ROLLBACK")
|
|
436
|
+
except Exception:
|
|
437
|
+
return
|
|
438
|
+
if logger is not None:
|
|
439
|
+
logger.debug("PostgreSQL rollback executed after transaction failure")
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
def normalize_postgres_empty_parameters(dialect: str, parameters: Any) -> Any:
|
|
443
|
+
"""Normalize empty parameter payloads for PostgreSQL drivers.
|
|
444
|
+
|
|
445
|
+
Args:
|
|
446
|
+
dialect: Active dialect identifier.
|
|
447
|
+
parameters: Parameter payload in any supported shape.
|
|
448
|
+
|
|
449
|
+
Returns:
|
|
450
|
+
Normalized parameter payload.
|
|
451
|
+
"""
|
|
452
|
+
if dialect == "postgres" and isinstance(parameters, dict) and not parameters:
|
|
453
|
+
return None
|
|
454
|
+
return parameters
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
def prepare_postgres_parameters(
|
|
458
|
+
parameters: Any,
|
|
459
|
+
parameter_casts: "dict[int, str]",
|
|
460
|
+
statement_config: "StatementConfig",
|
|
461
|
+
*,
|
|
462
|
+
dialect: str,
|
|
463
|
+
json_serializer: "Callable[[Any], str]",
|
|
464
|
+
) -> Any:
|
|
465
|
+
"""Prepare Postgres parameters with cast-aware coercion."""
|
|
466
|
+
postgres_compatible = normalize_postgres_empty_parameters(dialect, parameters)
|
|
467
|
+
if not parameter_casts:
|
|
468
|
+
return postgres_compatible
|
|
469
|
+
return prepare_parameters_with_casts(
|
|
470
|
+
postgres_compatible, parameter_casts, statement_config, dialect=dialect, json_serializer=json_serializer
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
def _create_adbc_error(error: Any, error_class: type[SQLSpecError], description: str) -> SQLSpecError:
|
|
475
|
+
"""Create an ADBC error instance without raising it."""
|
|
476
|
+
msg = f"ADBC {description}: {error}"
|
|
477
|
+
exc = error_class(msg)
|
|
478
|
+
exc.__cause__ = error
|
|
479
|
+
return exc
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
def create_mapped_exception(error: Any) -> SQLSpecError:
|
|
483
|
+
"""Map ADBC errors to SQLSpec exceptions.
|
|
484
|
+
|
|
485
|
+
This is a factory function that returns an exception instance rather than
|
|
486
|
+
raising. This pattern is more robust for use in __exit__ handlers and
|
|
487
|
+
avoids issues with exception control flow in different Python versions.
|
|
488
|
+
|
|
489
|
+
Mapping priority:
|
|
490
|
+
1. SQLSTATE codes (most reliable for ADBC drivers)
|
|
491
|
+
2. Error message patterns
|
|
492
|
+
3. Default SQLSpecError fallback
|
|
493
|
+
|
|
494
|
+
Args:
|
|
495
|
+
error: The ADBC exception to map
|
|
496
|
+
|
|
497
|
+
Returns:
|
|
498
|
+
A SQLSpec exception that wraps the original error
|
|
499
|
+
"""
|
|
500
|
+
sqlstate_attr = error.sqlstate if has_sqlstate(error) else None
|
|
501
|
+
sqlstate = sqlstate_attr if sqlstate_attr is not None else None
|
|
502
|
+
|
|
503
|
+
if sqlstate:
|
|
504
|
+
# Use centralized SQLSTATE mapping for specific codes
|
|
505
|
+
if sqlstate == "23505":
|
|
506
|
+
return _create_adbc_error(error, UniqueViolationError, "unique constraint violation")
|
|
507
|
+
if sqlstate == "23503":
|
|
508
|
+
return _create_adbc_error(error, ForeignKeyViolationError, "foreign key constraint violation")
|
|
509
|
+
if sqlstate == "23502":
|
|
510
|
+
return _create_adbc_error(error, NotNullViolationError, "not-null constraint violation")
|
|
511
|
+
if sqlstate == "23514":
|
|
512
|
+
return _create_adbc_error(error, CheckViolationError, "check constraint violation")
|
|
513
|
+
|
|
514
|
+
# Deadlock and serialization errors
|
|
515
|
+
if sqlstate == "40P01":
|
|
516
|
+
return _create_adbc_error(error, DeadlockError, "deadlock detected")
|
|
517
|
+
if sqlstate == "40001":
|
|
518
|
+
return _create_adbc_error(error, DeadlockError, "serialization failure")
|
|
519
|
+
|
|
520
|
+
# Query timeout/cancellation
|
|
521
|
+
if sqlstate == "57014":
|
|
522
|
+
return _create_adbc_error(error, QueryTimeoutError, "query canceled")
|
|
523
|
+
|
|
524
|
+
# Permission errors
|
|
525
|
+
if sqlstate == "42501":
|
|
526
|
+
return _create_adbc_error(error, PermissionDeniedError, "insufficient privilege")
|
|
527
|
+
if sqlstate == "28000":
|
|
528
|
+
return _create_adbc_error(error, PermissionDeniedError, "invalid authorization")
|
|
529
|
+
|
|
530
|
+
# Use centralized mapping for SQLSTATE class prefixes
|
|
531
|
+
exc_class = map_sqlstate_to_exception(sqlstate)
|
|
532
|
+
if exc_class is not None and exc_class is not SQLSpecError:
|
|
533
|
+
description = _get_sqlstate_description(sqlstate)
|
|
534
|
+
return _create_adbc_error(error, exc_class, description)
|
|
535
|
+
|
|
536
|
+
# Fallback for unmapped SQLSTATE codes
|
|
537
|
+
return _create_adbc_error(error, SQLSpecError, "database error")
|
|
538
|
+
|
|
539
|
+
# Message-based fallback when no SQLSTATE is available
|
|
540
|
+
error_msg = str(error).lower()
|
|
541
|
+
|
|
542
|
+
# Constraint violations
|
|
543
|
+
if "unique" in error_msg or "duplicate" in error_msg:
|
|
544
|
+
return _create_adbc_error(error, UniqueViolationError, "unique constraint violation")
|
|
545
|
+
if "foreign key" in error_msg:
|
|
546
|
+
return _create_adbc_error(error, ForeignKeyViolationError, "foreign key constraint violation")
|
|
547
|
+
if "not null" in error_msg or "null value" in error_msg:
|
|
548
|
+
return _create_adbc_error(error, NotNullViolationError, "not-null constraint violation")
|
|
549
|
+
if "check constraint" in error_msg:
|
|
550
|
+
return _create_adbc_error(error, CheckViolationError, "check constraint violation")
|
|
551
|
+
if "constraint" in error_msg:
|
|
552
|
+
return _create_adbc_error(error, IntegrityError, "integrity constraint violation")
|
|
553
|
+
|
|
554
|
+
# Deadlock/lock patterns
|
|
555
|
+
if "deadlock" in error_msg:
|
|
556
|
+
return _create_adbc_error(error, DeadlockError, "deadlock detected")
|
|
557
|
+
if "serialization" in error_msg or "concurrent update" in error_msg:
|
|
558
|
+
return _create_adbc_error(error, DeadlockError, "serialization failure")
|
|
559
|
+
|
|
560
|
+
# Timeout/cancellation patterns
|
|
561
|
+
if "timeout" in error_msg or "cancel" in error_msg or "interrupt" in error_msg:
|
|
562
|
+
return _create_adbc_error(error, QueryTimeoutError, "query timeout")
|
|
563
|
+
|
|
564
|
+
# Permission patterns
|
|
565
|
+
if "permission" in error_msg or "denied" in error_msg or "unauthorized" in error_msg:
|
|
566
|
+
return _create_adbc_error(error, PermissionDeniedError, "permission denied")
|
|
567
|
+
|
|
568
|
+
# Syntax errors
|
|
569
|
+
if "syntax" in error_msg:
|
|
570
|
+
return _create_adbc_error(error, SQLParsingError, "SQL parsing error")
|
|
571
|
+
|
|
572
|
+
# Connection errors
|
|
573
|
+
if "connection" in error_msg or "connect" in error_msg:
|
|
574
|
+
return _create_adbc_error(error, DatabaseConnectionError, "connection error")
|
|
575
|
+
|
|
576
|
+
return _create_adbc_error(error, SQLSpecError, "database error")
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
_SQLSTATE_CLASS_CODE_LEN = 2
|
|
580
|
+
|
|
581
|
+
# Module-level SQLSTATE descriptions (mypyc optimization - avoid dict creation per call)
|
|
582
|
+
_SQLSTATE_DESCRIPTIONS: dict[str, str] = {
|
|
583
|
+
"23": "integrity constraint violation",
|
|
584
|
+
"40": "transaction error",
|
|
585
|
+
"42": "SQL syntax error",
|
|
586
|
+
"08": "connection error",
|
|
587
|
+
"22": "data error",
|
|
588
|
+
"28": "authorization error",
|
|
589
|
+
"57": "operational error",
|
|
590
|
+
"02": "no data",
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
def _get_sqlstate_description(sqlstate: str) -> str:
|
|
595
|
+
"""Get a human-readable description for a SQLSTATE code class."""
|
|
596
|
+
class_code = sqlstate[:_SQLSTATE_CLASS_CODE_LEN] if len(sqlstate) >= _SQLSTATE_CLASS_CODE_LEN else sqlstate
|
|
597
|
+
return _SQLSTATE_DESCRIPTIONS.get(class_code, "database error")
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
def _identity(value: Any) -> Any:
|
|
601
|
+
return value
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def _convert_array_for_postgres_adbc(value: Any) -> Any:
|
|
605
|
+
"""Convert array values for PostgreSQL compatibility."""
|
|
606
|
+
|
|
607
|
+
if isinstance(value, tuple):
|
|
608
|
+
return list(value)
|
|
609
|
+
return value
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
def _get_type_coercion_map(dialect: str) -> "dict[type, Any]":
|
|
613
|
+
"""Return dialect-aware type coercion mapping for Arrow parameter handling."""
|
|
614
|
+
|
|
615
|
+
return {
|
|
616
|
+
datetime.datetime: _identity,
|
|
617
|
+
datetime.date: _identity,
|
|
618
|
+
datetime.time: _identity,
|
|
619
|
+
decimal.Decimal: float,
|
|
620
|
+
bool: _identity,
|
|
621
|
+
int: _identity,
|
|
622
|
+
float: _identity,
|
|
623
|
+
bytes: _identity,
|
|
624
|
+
tuple: _convert_array_for_postgres_adbc,
|
|
625
|
+
list: _convert_array_for_postgres_adbc,
|
|
626
|
+
dict: _identity,
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
def build_profile() -> "DriverParameterProfile":
|
|
631
|
+
"""Create the ADBC driver parameter profile."""
|
|
632
|
+
|
|
633
|
+
return DriverParameterProfile(
|
|
634
|
+
name="ADBC",
|
|
635
|
+
default_style=ParameterStyle.QMARK,
|
|
636
|
+
supported_styles={ParameterStyle.QMARK},
|
|
637
|
+
default_execution_style=ParameterStyle.QMARK,
|
|
638
|
+
supported_execution_styles={ParameterStyle.QMARK},
|
|
639
|
+
has_native_list_expansion=True,
|
|
640
|
+
preserve_parameter_format=True,
|
|
641
|
+
needs_static_script_compilation=False,
|
|
642
|
+
allow_mixed_parameter_styles=False,
|
|
643
|
+
preserve_original_params_for_many=False,
|
|
644
|
+
json_serializer_strategy="helper",
|
|
645
|
+
custom_type_coercions={
|
|
646
|
+
datetime.datetime: _identity,
|
|
647
|
+
datetime.date: _identity,
|
|
648
|
+
datetime.time: _identity,
|
|
649
|
+
decimal.Decimal: float,
|
|
650
|
+
bool: _identity,
|
|
651
|
+
int: _identity,
|
|
652
|
+
float: _identity,
|
|
653
|
+
bytes: _identity,
|
|
654
|
+
tuple: _convert_array_for_postgres_adbc,
|
|
655
|
+
list: _convert_array_for_postgres_adbc,
|
|
656
|
+
dict: _identity,
|
|
657
|
+
**build_uuid_coercions(native=True),
|
|
658
|
+
},
|
|
659
|
+
extras={
|
|
660
|
+
"type_coercion_overrides": {list: _convert_array_for_postgres_adbc, tuple: _convert_array_for_postgres_adbc}
|
|
661
|
+
},
|
|
662
|
+
)
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
driver_profile = build_profile()
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
def get_statement_config(detected_dialect: str) -> StatementConfig:
|
|
669
|
+
"""Create statement configuration for the specified dialect."""
|
|
670
|
+
default_style, supported_styles = DIALECT_PARAMETER_STYLES.get(
|
|
671
|
+
detected_dialect, (ParameterStyle.QMARK, [ParameterStyle.QMARK])
|
|
672
|
+
)
|
|
673
|
+
|
|
674
|
+
type_map = _get_type_coercion_map(detected_dialect)
|
|
675
|
+
|
|
676
|
+
sqlglot_dialect = "postgres" if detected_dialect == "postgresql" else detected_dialect
|
|
677
|
+
profile = driver_profile
|
|
678
|
+
|
|
679
|
+
parameter_overrides: dict[str, Any] = {
|
|
680
|
+
"default_parameter_style": default_style,
|
|
681
|
+
"supported_parameter_styles": set(supported_styles),
|
|
682
|
+
"default_execution_parameter_style": default_style,
|
|
683
|
+
"supported_execution_parameter_styles": set(supported_styles),
|
|
684
|
+
"type_coercion_map": type_map,
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
if detected_dialect == "duckdb":
|
|
688
|
+
parameter_overrides["preserve_parameter_format"] = False
|
|
689
|
+
parameter_overrides["supported_execution_parameter_styles"] = {ParameterStyle.QMARK, ParameterStyle.NUMERIC}
|
|
690
|
+
|
|
691
|
+
if detected_dialect in {"postgres", "postgresql"}:
|
|
692
|
+
parameter_overrides["ast_transformer"] = build_null_pruning_transform(dialect=sqlglot_dialect)
|
|
693
|
+
|
|
694
|
+
return build_statement_config_from_profile(
|
|
695
|
+
profile, parameter_overrides=parameter_overrides, statement_overrides={"dialect": sqlglot_dialect}
|
|
696
|
+
)
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
def _normalize_adbc_driver_features(processed_features: "dict[str, Any]") -> "dict[str, Any]":
|
|
700
|
+
if "strict_type_coercion" in processed_features and "enable_strict_type_coercion" not in processed_features:
|
|
701
|
+
processed_features["enable_strict_type_coercion"] = processed_features["strict_type_coercion"]
|
|
702
|
+
if "enable_strict_type_coercion" in processed_features and "strict_type_coercion" not in processed_features:
|
|
703
|
+
processed_features["strict_type_coercion"] = processed_features["enable_strict_type_coercion"]
|
|
704
|
+
|
|
705
|
+
if "arrow_extension_types" in processed_features and "enable_arrow_extension_types" not in processed_features:
|
|
706
|
+
processed_features["enable_arrow_extension_types"] = processed_features["arrow_extension_types"]
|
|
707
|
+
if "enable_arrow_extension_types" in processed_features and "arrow_extension_types" not in processed_features:
|
|
708
|
+
processed_features["arrow_extension_types"] = processed_features["enable_arrow_extension_types"]
|
|
709
|
+
|
|
710
|
+
return processed_features
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
def _apply_adbc_json_serializer(
|
|
714
|
+
statement_config: "StatementConfig", json_serializer: "Callable[[Any], str]"
|
|
715
|
+
) -> "StatementConfig":
|
|
716
|
+
"""Apply a JSON serializer to statement config while preserving list/tuple converters.
|
|
717
|
+
|
|
718
|
+
Args:
|
|
719
|
+
statement_config: Base statement configuration to update.
|
|
720
|
+
json_serializer: JSON serializer function.
|
|
721
|
+
|
|
722
|
+
Returns:
|
|
723
|
+
Updated statement configuration.
|
|
724
|
+
"""
|
|
725
|
+
parameter_config = statement_config.parameter_config
|
|
726
|
+
previous_list_converter = parameter_config.type_coercion_map.get(list)
|
|
727
|
+
previous_tuple_converter = parameter_config.type_coercion_map.get(tuple)
|
|
728
|
+
|
|
729
|
+
updated_parameter_config = parameter_config.with_json_serializers(json_serializer)
|
|
730
|
+
updated_map = dict(updated_parameter_config.type_coercion_map)
|
|
731
|
+
|
|
732
|
+
if previous_list_converter is not None:
|
|
733
|
+
updated_map[list] = previous_list_converter
|
|
734
|
+
if previous_tuple_converter is not None:
|
|
735
|
+
updated_map[tuple] = previous_tuple_converter
|
|
736
|
+
|
|
737
|
+
return statement_config.replace(parameter_config=updated_parameter_config.replace(type_coercion_map=updated_map))
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
def apply_driver_features(
|
|
741
|
+
statement_config: "StatementConfig", driver_features: "Mapping[str, Any] | None"
|
|
742
|
+
) -> "tuple[StatementConfig, dict[str, Any]]":
|
|
743
|
+
"""Apply ADBC driver feature defaults to the statement config.
|
|
744
|
+
|
|
745
|
+
Args:
|
|
746
|
+
statement_config: Base statement configuration.
|
|
747
|
+
driver_features: Optional driver feature overrides.
|
|
748
|
+
|
|
749
|
+
Returns:
|
|
750
|
+
Updated statement configuration and normalized driver features.
|
|
751
|
+
"""
|
|
752
|
+
processed_features: dict[str, Any] = dict(driver_features) if driver_features else {}
|
|
753
|
+
processed_features = _normalize_adbc_driver_features(processed_features)
|
|
754
|
+
|
|
755
|
+
json_serializer = cast("Callable[[Any], str] | None", processed_features.setdefault("json_serializer", to_json))
|
|
756
|
+
processed_features.setdefault("enable_cast_detection", True)
|
|
757
|
+
processed_features.setdefault("strict_type_coercion", False)
|
|
758
|
+
processed_features.setdefault("enable_strict_type_coercion", processed_features["strict_type_coercion"])
|
|
759
|
+
processed_features.setdefault("arrow_extension_types", True)
|
|
760
|
+
processed_features.setdefault("enable_arrow_extension_types", processed_features["arrow_extension_types"])
|
|
761
|
+
processed_features.setdefault("enable_pgvector", PGVECTOR_INSTALLED)
|
|
762
|
+
processed_features.setdefault("enable_paradedb", True)
|
|
763
|
+
|
|
764
|
+
if json_serializer is not None:
|
|
765
|
+
statement_config = _apply_adbc_json_serializer(statement_config, json_serializer)
|
|
766
|
+
|
|
767
|
+
return statement_config, processed_features
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
def resolve_column_names(description: "list[Any] | None", cache: "dict[int, tuple[Any, list[str]]]") -> list[str]:
|
|
771
|
+
"""Resolve and cache ADBC cursor description column names."""
|
|
772
|
+
if not description:
|
|
773
|
+
return []
|
|
774
|
+
|
|
775
|
+
cache_key = id(description)
|
|
776
|
+
cached = cache.get(cache_key)
|
|
777
|
+
if cached is not None and cached[0] is description:
|
|
778
|
+
return cached[1]
|
|
779
|
+
|
|
780
|
+
column_names = [col[0] for col in description]
|
|
781
|
+
if len(cache) >= COLUMN_CACHE_MAX_SIZE:
|
|
782
|
+
cache.pop(next(iter(cache)))
|
|
783
|
+
cache[cache_key] = (description, column_names)
|
|
784
|
+
return column_names
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
def collect_rows(
|
|
788
|
+
fetched_data: "list[Any] | None", description: "list[Any] | None", *, column_names: "list[str] | None" = None
|
|
789
|
+
) -> "tuple[list[Any], list[str]]":
|
|
790
|
+
"""Collect ADBC rows and column names.
|
|
791
|
+
|
|
792
|
+
Returns raw data without dict conversion. The row format is detected
|
|
793
|
+
by the driver and passed to ``create_execution_result`` so that
|
|
794
|
+
``SQLResult`` can handle lazy dict materialisation.
|
|
795
|
+
|
|
796
|
+
Args:
|
|
797
|
+
fetched_data: Rows returned from cursor.fetchall().
|
|
798
|
+
description: Cursor description metadata.
|
|
799
|
+
column_names: Optional precomputed column names.
|
|
800
|
+
|
|
801
|
+
Returns:
|
|
802
|
+
Tuple of (rows, column_names).
|
|
803
|
+
"""
|
|
804
|
+
if not description:
|
|
805
|
+
return [], []
|
|
806
|
+
resolved_column_names = [col[0] for col in description] if column_names is None else column_names
|
|
807
|
+
if not fetched_data:
|
|
808
|
+
return [], resolved_column_names
|
|
809
|
+
return fetched_data, resolved_column_names
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
def resolve_rowcount(cursor: Any) -> int:
|
|
813
|
+
"""Resolve rowcount from an ADBC cursor.
|
|
814
|
+
|
|
815
|
+
Args:
|
|
816
|
+
cursor: ADBC cursor with optional rowcount metadata.
|
|
817
|
+
|
|
818
|
+
Returns:
|
|
819
|
+
Rowcount value or -1 when unavailable.
|
|
820
|
+
"""
|
|
821
|
+
if not has_rowcount(cursor):
|
|
822
|
+
return -1
|
|
823
|
+
rowcount = cursor.rowcount
|
|
824
|
+
if isinstance(rowcount, int):
|
|
825
|
+
return rowcount
|
|
826
|
+
return -1
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
def resolve_many_rowcount(cursor: Any, parameter_sets: Any, *, fallback_count: "int | None" = None) -> int:
|
|
830
|
+
"""Resolve execute_many rowcount with a parameter-count fallback.
|
|
831
|
+
|
|
832
|
+
Args:
|
|
833
|
+
cursor: ADBC cursor with optional rowcount metadata.
|
|
834
|
+
parameter_sets: Execute-many payload.
|
|
835
|
+
fallback_count: Optional precomputed execute-many payload size.
|
|
836
|
+
|
|
837
|
+
Returns:
|
|
838
|
+
Driver rowcount when available, otherwise parameter count when sized.
|
|
839
|
+
"""
|
|
840
|
+
rowcount = resolve_rowcount(cursor)
|
|
841
|
+
if rowcount != -1:
|
|
842
|
+
return rowcount
|
|
843
|
+
if fallback_count is not None:
|
|
844
|
+
return fallback_count
|
|
845
|
+
if isinstance(parameter_sets, Sized):
|
|
846
|
+
return len(parameter_sets)
|
|
847
|
+
return -1
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
def normalize_script_rowcount(previous: int, cursor: Any) -> int:
|
|
851
|
+
"""Normalize script rowcount using the latest cursor value when present.
|
|
852
|
+
|
|
853
|
+
Args:
|
|
854
|
+
previous: Previously recorded rowcount.
|
|
855
|
+
cursor: ADBC cursor with optional rowcount metadata.
|
|
856
|
+
|
|
857
|
+
Returns:
|
|
858
|
+
Updated rowcount value.
|
|
859
|
+
"""
|
|
860
|
+
rowcount = resolve_rowcount(cursor)
|
|
861
|
+
return rowcount if rowcount != -1 else previous
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
def resolve_parameter_casts(statement: "SQL") -> "dict[int, str]":
|
|
865
|
+
"""Return parameter cast mapping from a compiled SQL statement."""
|
|
866
|
+
processed_state = statement.get_processed_state()
|
|
867
|
+
if processed_state is not Empty:
|
|
868
|
+
return processed_state.parameter_casts or {}
|
|
869
|
+
return {}
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
def _get_type_coercion_dispatcher(
|
|
873
|
+
type_map: "dict[type, Callable[[Any], Any]]",
|
|
874
|
+
) -> "TypeDispatcher[Callable[[Any], Any]]":
|
|
875
|
+
fallback_items = tuple(type_map.items())
|
|
876
|
+
dispatcher = _TYPE_COERCION_DISPATCHERS.get(fallback_items)
|
|
877
|
+
if dispatcher is not None:
|
|
878
|
+
return dispatcher
|
|
879
|
+
|
|
880
|
+
dispatcher = TypeDispatcher["Callable[[Any], Any]"]()
|
|
881
|
+
dispatcher.register_all(fallback_items)
|
|
882
|
+
_TYPE_COERCION_DISPATCHERS[fallback_items] = dispatcher
|
|
883
|
+
return dispatcher
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
def prepare_parameters_with_casts(
|
|
887
|
+
parameters: Any,
|
|
888
|
+
parameter_casts: "dict[int, str]",
|
|
889
|
+
statement_config: "StatementConfig",
|
|
890
|
+
*,
|
|
891
|
+
dialect: str,
|
|
892
|
+
json_serializer: "Callable[[Any], str]",
|
|
893
|
+
) -> Any:
|
|
894
|
+
"""Prepare parameters with cast-aware type coercion for ADBC."""
|
|
895
|
+
json_encoder = statement_config.parameter_config.json_serializer or json_serializer
|
|
896
|
+
|
|
897
|
+
if isinstance(parameters, (list, tuple)):
|
|
898
|
+
result: list[Any] = []
|
|
899
|
+
converter = get_adbc_type_converter(dialect)
|
|
900
|
+
type_map = statement_config.parameter_config.type_coercion_map
|
|
901
|
+
dispatcher = _get_type_coercion_dispatcher(type_map) if type_map else None
|
|
902
|
+
for idx, param in enumerate(parameters, start=1):
|
|
903
|
+
cast_type = parameter_casts.get(idx, "").upper()
|
|
904
|
+
if cast_type in {"JSON", "JSONB", "TYPE.JSON", "TYPE.JSONB"}:
|
|
905
|
+
if isinstance(param, dict):
|
|
906
|
+
result.append(json_encoder(param))
|
|
907
|
+
else:
|
|
908
|
+
result.append(param)
|
|
909
|
+
elif isinstance(param, dict):
|
|
910
|
+
result.append(converter.convert_dict(param))
|
|
911
|
+
else:
|
|
912
|
+
if type_map and dispatcher is not None:
|
|
913
|
+
exact_converter = type_map.get(type(param))
|
|
914
|
+
if exact_converter is not None and type(param) is not dict:
|
|
915
|
+
param = exact_converter(param)
|
|
916
|
+
else:
|
|
917
|
+
converter_func = dispatcher.get(param)
|
|
918
|
+
if converter_func is not None and type(param) is not dict:
|
|
919
|
+
param = converter_func(param)
|
|
920
|
+
result.append(param)
|
|
921
|
+
return tuple(result) if isinstance(parameters, tuple) else result
|
|
922
|
+
return parameters
|