sqlspec 0.36.0__cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.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.
- ac8f31065839703b4e70__mypyc.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/__init__.py +140 -0
- sqlspec/__main__.py +12 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_serialization.py +315 -0
- sqlspec/_typing.py +700 -0
- sqlspec/adapters/__init__.py +0 -0
- sqlspec/adapters/adbc/__init__.py +5 -0
- sqlspec/adapters/adbc/_typing.py +82 -0
- sqlspec/adapters/adbc/adk/__init__.py +5 -0
- sqlspec/adapters/adbc/adk/store.py +1273 -0
- sqlspec/adapters/adbc/config.py +295 -0
- sqlspec/adapters/adbc/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/adbc/core.py +735 -0
- sqlspec/adapters/adbc/data_dictionary.py +334 -0
- sqlspec/adapters/adbc/driver.py +529 -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 +502 -0
- sqlspec/adapters/adbc/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/adbc/type_converter.py +140 -0
- sqlspec/adapters/aiosqlite/__init__.py +25 -0
- sqlspec/adapters/aiosqlite/_typing.py +82 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +818 -0
- sqlspec/adapters/aiosqlite/config.py +334 -0
- sqlspec/adapters/aiosqlite/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/aiosqlite/core.py +315 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +208 -0
- sqlspec/adapters/aiosqlite/driver.py +313 -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.py +533 -0
- sqlspec/adapters/asyncmy/__init__.py +21 -0
- sqlspec/adapters/asyncmy/_typing.py +87 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +703 -0
- sqlspec/adapters/asyncmy/config.py +302 -0
- sqlspec/adapters/asyncmy/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/asyncmy/core.py +360 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +124 -0
- sqlspec/adapters/asyncmy/driver.py +383 -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 +19 -0
- sqlspec/adapters/asyncpg/_typing.py +88 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +748 -0
- sqlspec/adapters/asyncpg/config.py +569 -0
- sqlspec/adapters/asyncpg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/asyncpg/core.py +367 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +162 -0
- sqlspec/adapters/asyncpg/driver.py +487 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/backend.py +286 -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 +14 -0
- sqlspec/adapters/bigquery/_typing.py +86 -0
- sqlspec/adapters/bigquery/adk/__init__.py +5 -0
- sqlspec/adapters/bigquery/adk/store.py +827 -0
- sqlspec/adapters/bigquery/config.py +353 -0
- sqlspec/adapters/bigquery/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/bigquery/core.py +715 -0
- sqlspec/adapters/bigquery/data_dictionary.py +128 -0
- sqlspec/adapters/bigquery/driver.py +548 -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.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/bigquery/type_converter.py +107 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +24 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +72 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +410 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +238 -0
- sqlspec/adapters/cockroach_asyncpg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +55 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +107 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +144 -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 +38 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +129 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +13 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +868 -0
- sqlspec/adapters/cockroach_psycopg/config.py +484 -0
- sqlspec/adapters/cockroach_psycopg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +63 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +215 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +284 -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 +325 -0
- sqlspec/adapters/duckdb/__init__.py +25 -0
- sqlspec/adapters/duckdb/_typing.py +81 -0
- sqlspec/adapters/duckdb/adk/__init__.py +14 -0
- sqlspec/adapters/duckdb/adk/store.py +850 -0
- sqlspec/adapters/duckdb/config.py +463 -0
- sqlspec/adapters/duckdb/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/duckdb/core.py +257 -0
- sqlspec/adapters/duckdb/data_dictionary.py +140 -0
- sqlspec/adapters/duckdb/driver.py +430 -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.py +293 -0
- sqlspec/adapters/duckdb/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/duckdb/type_converter.py +118 -0
- sqlspec/adapters/mock/__init__.py +72 -0
- sqlspec/adapters/mock/_typing.py +147 -0
- sqlspec/adapters/mock/config.py +483 -0
- sqlspec/adapters/mock/core.py +319 -0
- sqlspec/adapters/mock/data_dictionary.py +366 -0
- sqlspec/adapters/mock/driver.py +721 -0
- sqlspec/adapters/mysqlconnector/__init__.py +36 -0
- sqlspec/adapters/mysqlconnector/_typing.py +141 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +15 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +1060 -0
- sqlspec/adapters/mysqlconnector/config.py +394 -0
- sqlspec/adapters/mysqlconnector/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/mysqlconnector/core.py +303 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +235 -0
- sqlspec/adapters/mysqlconnector/driver.py +483 -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 +60 -0
- sqlspec/adapters/oracledb/_numpy_handlers.py +141 -0
- sqlspec/adapters/oracledb/_typing.py +182 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +166 -0
- sqlspec/adapters/oracledb/adk/__init__.py +10 -0
- sqlspec/adapters/oracledb/adk/store.py +2369 -0
- sqlspec/adapters/oracledb/config.py +550 -0
- sqlspec/adapters/oracledb/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/oracledb/core.py +543 -0
- sqlspec/adapters/oracledb/data_dictionary.py +536 -0
- sqlspec/adapters/oracledb/driver.py +1229 -0
- sqlspec/adapters/oracledb/events/__init__.py +16 -0
- sqlspec/adapters/oracledb/events/backend.py +347 -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 +535 -0
- sqlspec/adapters/oracledb/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/oracledb/type_converter.py +211 -0
- sqlspec/adapters/psqlpy/__init__.py +17 -0
- sqlspec/adapters/psqlpy/_typing.py +79 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +766 -0
- sqlspec/adapters/psqlpy/config.py +304 -0
- sqlspec/adapters/psqlpy/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psqlpy/core.py +480 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +126 -0
- sqlspec/adapters/psqlpy/driver.py +438 -0
- sqlspec/adapters/psqlpy/events/__init__.py +6 -0
- sqlspec/adapters/psqlpy/events/backend.py +310 -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.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +113 -0
- sqlspec/adapters/psycopg/__init__.py +32 -0
- sqlspec/adapters/psycopg/_typing.py +164 -0
- sqlspec/adapters/psycopg/adk/__init__.py +10 -0
- sqlspec/adapters/psycopg/adk/store.py +1387 -0
- sqlspec/adapters/psycopg/config.py +576 -0
- sqlspec/adapters/psycopg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psycopg/core.py +450 -0
- sqlspec/adapters/psycopg/data_dictionary.py +289 -0
- sqlspec/adapters/psycopg/driver.py +975 -0
- sqlspec/adapters/psycopg/events/__init__.py +20 -0
- sqlspec/adapters/psycopg/events/backend.py +458 -0
- sqlspec/adapters/psycopg/events/store.py +42 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +552 -0
- sqlspec/adapters/psycopg/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psycopg/type_converter.py +93 -0
- sqlspec/adapters/pymysql/__init__.py +21 -0
- sqlspec/adapters/pymysql/_typing.py +71 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +540 -0
- sqlspec/adapters/pymysql/config.py +195 -0
- sqlspec/adapters/pymysql/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/pymysql/core.py +299 -0
- sqlspec/adapters/pymysql/data_dictionary.py +122 -0
- sqlspec/adapters/pymysql/driver.py +259 -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.py +137 -0
- sqlspec/adapters/spanner/__init__.py +40 -0
- sqlspec/adapters/spanner/_typing.py +86 -0
- sqlspec/adapters/spanner/adk/__init__.py +5 -0
- sqlspec/adapters/spanner/adk/store.py +732 -0
- sqlspec/adapters/spanner/config.py +352 -0
- sqlspec/adapters/spanner/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/spanner/core.py +188 -0
- sqlspec/adapters/spanner/data_dictionary.py +120 -0
- sqlspec/adapters/spanner/dialect/__init__.py +6 -0
- sqlspec/adapters/spanner/dialect/_spangres.py +57 -0
- sqlspec/adapters/spanner/dialect/_spanner.py +130 -0
- sqlspec/adapters/spanner/driver.py +373 -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.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/spanner/type_converter.py +331 -0
- sqlspec/adapters/sqlite/__init__.py +19 -0
- sqlspec/adapters/sqlite/_typing.py +80 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +958 -0
- sqlspec/adapters/sqlite/config.py +280 -0
- sqlspec/adapters/sqlite/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/sqlite/core.py +312 -0
- sqlspec/adapters/sqlite/data_dictionary.py +202 -0
- sqlspec/adapters/sqlite/driver.py +359 -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.py +198 -0
- sqlspec/adapters/sqlite/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/base.py +747 -0
- sqlspec/builder/__init__.py +179 -0
- sqlspec/builder/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_base.py +1022 -0
- sqlspec/builder/_column.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_column.py +521 -0
- sqlspec/builder/_ddl.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_ddl.py +1642 -0
- sqlspec/builder/_delete.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_delete.py +95 -0
- sqlspec/builder/_dml.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_dml.py +365 -0
- sqlspec/builder/_explain.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_explain.py +579 -0
- sqlspec/builder/_expression_wrappers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_expression_wrappers.py +46 -0
- sqlspec/builder/_factory.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_factory.py +1697 -0
- sqlspec/builder/_insert.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_insert.py +328 -0
- sqlspec/builder/_join.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_join.py +499 -0
- sqlspec/builder/_merge.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_merge.py +821 -0
- sqlspec/builder/_parsing_utils.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_parsing_utils.py +297 -0
- sqlspec/builder/_select.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_select.py +1660 -0
- sqlspec/builder/_temporal.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_temporal.py +139 -0
- sqlspec/builder/_update.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_update.py +173 -0
- sqlspec/builder/_vector_expressions.py +267 -0
- sqlspec/cli.py +911 -0
- sqlspec/config.py +1755 -0
- sqlspec/core/__init__.py +374 -0
- sqlspec/core/_correlation.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/_correlation.py +176 -0
- sqlspec/core/cache.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/cache.py +1069 -0
- sqlspec/core/compiler.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/compiler.py +954 -0
- sqlspec/core/explain.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/explain.py +275 -0
- sqlspec/core/filters.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/filters.py +952 -0
- sqlspec/core/hashing.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/hashing.py +262 -0
- sqlspec/core/metrics.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/metrics.py +83 -0
- sqlspec/core/parameters/__init__.py +71 -0
- sqlspec/core/parameters/_alignment.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_alignment.py +270 -0
- sqlspec/core/parameters/_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_converter.py +543 -0
- sqlspec/core/parameters/_processor.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_processor.py +505 -0
- sqlspec/core/parameters/_registry.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_registry.py +206 -0
- sqlspec/core/parameters/_transformers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_transformers.py +292 -0
- sqlspec/core/parameters/_types.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_types.py +499 -0
- sqlspec/core/parameters/_validator.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_validator.py +180 -0
- sqlspec/core/pipeline.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/pipeline.py +319 -0
- sqlspec/core/query_modifiers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/query_modifiers.py +437 -0
- sqlspec/core/result/__init__.py +23 -0
- sqlspec/core/result/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/result/_base.py +1121 -0
- sqlspec/core/result/_io.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/result/_io.py +28 -0
- sqlspec/core/splitter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/splitter.py +966 -0
- sqlspec/core/stack.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/stack.py +163 -0
- sqlspec/core/statement.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/statement.py +1503 -0
- sqlspec/core/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/type_converter.py +339 -0
- sqlspec/data_dictionary/__init__.py +22 -0
- sqlspec/data_dictionary/_loader.py +123 -0
- sqlspec/data_dictionary/_registry.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/_registry.py +74 -0
- sqlspec/data_dictionary/_types.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/_types.py +121 -0
- sqlspec/data_dictionary/dialects/__init__.py +21 -0
- sqlspec/data_dictionary/dialects/bigquery.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/bigquery.py +49 -0
- sqlspec/data_dictionary/dialects/cockroachdb.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb.py +43 -0
- sqlspec/data_dictionary/dialects/duckdb.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/duckdb.py +47 -0
- sqlspec/data_dictionary/dialects/mysql.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/mysql.py +42 -0
- sqlspec/data_dictionary/dialects/oracle.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/oracle.py +34 -0
- sqlspec/data_dictionary/dialects/postgres.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/postgres.py +46 -0
- sqlspec/data_dictionary/dialects/spanner.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/spanner.py +37 -0
- sqlspec/data_dictionary/dialects/sqlite.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/sqlite.py +42 -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/driver/__init__.py +32 -0
- sqlspec/driver/_async.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_async.py +1737 -0
- sqlspec/driver/_common.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_common.py +1478 -0
- sqlspec/driver/_sql_helpers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_sql_helpers.py +148 -0
- sqlspec/driver/_storage_helpers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_storage_helpers.py +144 -0
- sqlspec/driver/_sync.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_sync.py +1710 -0
- sqlspec/exceptions.py +338 -0
- sqlspec/extensions/__init__.py +0 -0
- sqlspec/extensions/adk/__init__.py +70 -0
- sqlspec/extensions/adk/_types.py +51 -0
- sqlspec/extensions/adk/converters.py +172 -0
- sqlspec/extensions/adk/memory/__init__.py +69 -0
- sqlspec/extensions/adk/memory/_types.py +30 -0
- sqlspec/extensions/adk/memory/converters.py +149 -0
- sqlspec/extensions/adk/memory/service.py +217 -0
- sqlspec/extensions/adk/memory/store.py +569 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +246 -0
- sqlspec/extensions/adk/migrations/__init__.py +0 -0
- sqlspec/extensions/adk/service.py +225 -0
- sqlspec/extensions/adk/store.py +567 -0
- sqlspec/extensions/events/__init__.py +51 -0
- sqlspec/extensions/events/_channel.py +703 -0
- sqlspec/extensions/events/_hints.py +45 -0
- sqlspec/extensions/events/_models.py +23 -0
- sqlspec/extensions/events/_payload.py +69 -0
- sqlspec/extensions/events/_protocols.py +134 -0
- sqlspec/extensions/events/_queue.py +461 -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 +19 -0
- sqlspec/extensions/fastapi/extension.py +351 -0
- sqlspec/extensions/fastapi/providers.py +607 -0
- sqlspec/extensions/flask/__init__.py +37 -0
- sqlspec/extensions/flask/_state.py +76 -0
- sqlspec/extensions/flask/_utils.py +71 -0
- sqlspec/extensions/flask/extension.py +519 -0
- sqlspec/extensions/litestar/__init__.py +28 -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 +671 -0
- sqlspec/extensions/litestar/providers.py +526 -0
- sqlspec/extensions/litestar/store.py +296 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +113 -0
- sqlspec/extensions/starlette/__init__.py +19 -0
- sqlspec/extensions/starlette/_state.py +30 -0
- sqlspec/extensions/starlette/_utils.py +96 -0
- sqlspec/extensions/starlette/extension.py +346 -0
- sqlspec/extensions/starlette/middleware.py +235 -0
- sqlspec/loader.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/loader.py +702 -0
- sqlspec/migrations/__init__.py +36 -0
- sqlspec/migrations/base.py +731 -0
- sqlspec/migrations/commands.py +1232 -0
- sqlspec/migrations/context.py +157 -0
- sqlspec/migrations/fix.py +204 -0
- sqlspec/migrations/loaders.py +443 -0
- sqlspec/migrations/runner.py +1172 -0
- sqlspec/migrations/templates.py +234 -0
- sqlspec/migrations/tracker.py +611 -0
- sqlspec/migrations/utils.py +256 -0
- sqlspec/migrations/validation.py +207 -0
- sqlspec/migrations/version.py +446 -0
- sqlspec/observability/__init__.py +55 -0
- sqlspec/observability/_common.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_common.py +77 -0
- sqlspec/observability/_config.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_config.py +348 -0
- sqlspec/observability/_diagnostics.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_diagnostics.py +74 -0
- sqlspec/observability/_dispatcher.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_dispatcher.py +152 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_aws.py +102 -0
- sqlspec/observability/_formatters/_azure.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_azure.py +96 -0
- sqlspec/observability/_formatters/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_base.py +57 -0
- sqlspec/observability/_formatters/_gcp.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_gcp.py +131 -0
- sqlspec/observability/_formatting.py +58 -0
- sqlspec/observability/_observer.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_observer.py +357 -0
- sqlspec/observability/_runtime.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_runtime.py +420 -0
- sqlspec/observability/_sampling.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_sampling.py +188 -0
- sqlspec/observability/_spans.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_spans.py +161 -0
- sqlspec/protocols.py +916 -0
- sqlspec/py.typed +0 -0
- sqlspec/storage/__init__.py +48 -0
- sqlspec/storage/_utils.py +104 -0
- sqlspec/storage/backends/__init__.py +1 -0
- sqlspec/storage/backends/base.py +253 -0
- sqlspec/storage/backends/fsspec.py +529 -0
- sqlspec/storage/backends/local.py +441 -0
- sqlspec/storage/backends/obstore.py +916 -0
- sqlspec/storage/errors.py +104 -0
- sqlspec/storage/pipeline.py +582 -0
- sqlspec/storage/registry.py +301 -0
- sqlspec/typing.py +395 -0
- sqlspec/utils/__init__.py +7 -0
- sqlspec/utils/arrow_helpers.py +318 -0
- sqlspec/utils/config_tools.py +332 -0
- sqlspec/utils/correlation.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/correlation.py +134 -0
- sqlspec/utils/deprecation.py +190 -0
- sqlspec/utils/fixtures.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/fixtures.py +258 -0
- sqlspec/utils/logging.py +222 -0
- sqlspec/utils/module_loader.py +306 -0
- sqlspec/utils/portal.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/portal.py +375 -0
- sqlspec/utils/schema.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/schema.py +485 -0
- sqlspec/utils/serializers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/serializers.py +408 -0
- sqlspec/utils/singleton.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/singleton.py +41 -0
- sqlspec/utils/sync_tools.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/sync_tools.py +311 -0
- sqlspec/utils/text.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/text.py +108 -0
- sqlspec/utils/type_converters.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/type_converters.py +128 -0
- sqlspec/utils/type_guards.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/type_guards.py +1360 -0
- sqlspec/utils/uuids.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/uuids.py +225 -0
- sqlspec-0.36.0.dist-info/METADATA +205 -0
- sqlspec-0.36.0.dist-info/RECORD +531 -0
- sqlspec-0.36.0.dist-info/WHEEL +7 -0
- sqlspec-0.36.0.dist-info/entry_points.txt +2 -0
- sqlspec-0.36.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
"""AsyncPG PostgreSQL driver implementation for async PostgreSQL operations."""
|
|
2
|
+
|
|
3
|
+
from collections import OrderedDict
|
|
4
|
+
from io import BytesIO
|
|
5
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
6
|
+
|
|
7
|
+
import asyncpg
|
|
8
|
+
|
|
9
|
+
from sqlspec.adapters.asyncpg.core import (
|
|
10
|
+
PREPARED_STATEMENT_CACHE_SIZE,
|
|
11
|
+
NormalizedStackOperation,
|
|
12
|
+
collect_rows,
|
|
13
|
+
create_mapped_exception,
|
|
14
|
+
default_statement_config,
|
|
15
|
+
driver_profile,
|
|
16
|
+
invoke_prepared_statement,
|
|
17
|
+
parse_status,
|
|
18
|
+
)
|
|
19
|
+
from sqlspec.adapters.asyncpg.data_dictionary import AsyncpgDataDictionary
|
|
20
|
+
from sqlspec.core import (
|
|
21
|
+
SQL,
|
|
22
|
+
StackResult,
|
|
23
|
+
StatementStack,
|
|
24
|
+
create_sql_result,
|
|
25
|
+
get_cache_config,
|
|
26
|
+
is_copy_from_operation,
|
|
27
|
+
is_copy_operation,
|
|
28
|
+
register_driver_profile,
|
|
29
|
+
)
|
|
30
|
+
from sqlspec.driver import AsyncDriverAdapterBase, StackExecutionObserver, describe_stack_statement
|
|
31
|
+
from sqlspec.exceptions import SQLSpecError, StackExecutionError
|
|
32
|
+
from sqlspec.utils.logging import get_logger
|
|
33
|
+
from sqlspec.utils.type_guards import has_sqlstate
|
|
34
|
+
|
|
35
|
+
if TYPE_CHECKING:
|
|
36
|
+
from collections.abc import Sequence
|
|
37
|
+
|
|
38
|
+
from sqlspec.adapters.asyncpg._typing import AsyncpgConnection, AsyncpgPreparedStatement
|
|
39
|
+
from sqlspec.core import ArrowResult, SQLResult, StatementConfig
|
|
40
|
+
from sqlspec.driver import ExecutionResult
|
|
41
|
+
from sqlspec.storage import StorageBridgeJob, StorageDestination, StorageFormat, StorageTelemetry
|
|
42
|
+
|
|
43
|
+
from sqlspec.adapters.asyncpg._typing import AsyncpgSessionContext
|
|
44
|
+
|
|
45
|
+
__all__ = ("AsyncpgCursor", "AsyncpgDriver", "AsyncpgExceptionHandler", "AsyncpgSessionContext")
|
|
46
|
+
|
|
47
|
+
logger = get_logger("sqlspec.adapters.asyncpg")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AsyncpgCursor:
|
|
51
|
+
"""Context manager for AsyncPG cursor management."""
|
|
52
|
+
|
|
53
|
+
__slots__ = ("connection",)
|
|
54
|
+
|
|
55
|
+
def __init__(self, connection: "AsyncpgConnection") -> None:
|
|
56
|
+
self.connection = connection
|
|
57
|
+
|
|
58
|
+
async def __aenter__(self) -> "AsyncpgConnection":
|
|
59
|
+
return self.connection
|
|
60
|
+
|
|
61
|
+
async def __aexit__(self, *_: Any) -> None: ...
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class AsyncpgExceptionHandler:
|
|
65
|
+
"""Async context manager for handling AsyncPG database exceptions.
|
|
66
|
+
|
|
67
|
+
Maps PostgreSQL SQLSTATE error codes to specific SQLSpec exceptions
|
|
68
|
+
for better error handling in application code.
|
|
69
|
+
|
|
70
|
+
Uses deferred exception pattern for mypyc compatibility: exceptions
|
|
71
|
+
are stored in pending_exception rather than raised from __aexit__
|
|
72
|
+
to avoid ABI boundary violations with compiled code.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
__slots__ = ("pending_exception",)
|
|
76
|
+
|
|
77
|
+
def __init__(self) -> None:
|
|
78
|
+
self.pending_exception: Exception | None = None
|
|
79
|
+
|
|
80
|
+
async def __aenter__(self) -> "AsyncpgExceptionHandler":
|
|
81
|
+
return self
|
|
82
|
+
|
|
83
|
+
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:
|
|
84
|
+
if exc_val is None:
|
|
85
|
+
return False
|
|
86
|
+
if isinstance(exc_val, asyncpg.PostgresError) or has_sqlstate(exc_val):
|
|
87
|
+
self.pending_exception = create_mapped_exception(exc_val)
|
|
88
|
+
return True
|
|
89
|
+
return False
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class AsyncpgDriver(AsyncDriverAdapterBase):
|
|
93
|
+
"""AsyncPG PostgreSQL driver for async database operations.
|
|
94
|
+
|
|
95
|
+
Supports COPY operations, numeric parameter style handling, PostgreSQL
|
|
96
|
+
exception handling, transaction management, SQL statement compilation
|
|
97
|
+
and caching, and parameter processing with type coercion.
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
__slots__ = ("_data_dictionary", "_prepared_statements")
|
|
101
|
+
dialect = "postgres"
|
|
102
|
+
|
|
103
|
+
def __init__(
|
|
104
|
+
self,
|
|
105
|
+
connection: "AsyncpgConnection",
|
|
106
|
+
statement_config: "StatementConfig | None" = None,
|
|
107
|
+
driver_features: "dict[str, Any] | None" = None,
|
|
108
|
+
) -> None:
|
|
109
|
+
if statement_config is None:
|
|
110
|
+
statement_config = default_statement_config.replace(
|
|
111
|
+
enable_caching=get_cache_config().compiled_cache_enabled
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
super().__init__(connection=connection, statement_config=statement_config, driver_features=driver_features)
|
|
115
|
+
self._data_dictionary: AsyncpgDataDictionary | None = None
|
|
116
|
+
self._prepared_statements: OrderedDict[str, AsyncpgPreparedStatement] = OrderedDict()
|
|
117
|
+
|
|
118
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
119
|
+
# CORE DISPATCH METHODS
|
|
120
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
121
|
+
|
|
122
|
+
async def dispatch_execute(self, cursor: "AsyncpgConnection", statement: "SQL") -> "ExecutionResult":
|
|
123
|
+
"""Execute single SQL statement.
|
|
124
|
+
|
|
125
|
+
Handles both SELECT queries and non-SELECT operations.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
cursor: AsyncPG connection object
|
|
129
|
+
statement: SQL statement to execute
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
ExecutionResult with statement execution details
|
|
133
|
+
"""
|
|
134
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
135
|
+
params: tuple[Any, ...] = cast("tuple[Any, ...]", prepared_parameters) if prepared_parameters else ()
|
|
136
|
+
|
|
137
|
+
if statement.returns_rows():
|
|
138
|
+
records = await cursor.fetch(sql, *params) if params else await cursor.fetch(sql)
|
|
139
|
+
data, column_names = collect_rows(records)
|
|
140
|
+
|
|
141
|
+
return self.create_execution_result(
|
|
142
|
+
cursor, selected_data=data, column_names=column_names, data_row_count=len(data), is_select_result=True
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
result = await cursor.execute(sql, *params) if params else await cursor.execute(sql)
|
|
146
|
+
|
|
147
|
+
affected_rows = parse_status(result)
|
|
148
|
+
|
|
149
|
+
return self.create_execution_result(cursor, rowcount_override=affected_rows)
|
|
150
|
+
|
|
151
|
+
async def dispatch_execute_many(self, cursor: "AsyncpgConnection", statement: "SQL") -> "ExecutionResult":
|
|
152
|
+
"""Execute SQL with multiple parameter sets using AsyncPG's executemany.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
cursor: AsyncPG connection object
|
|
156
|
+
statement: SQL statement with multiple parameter sets
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
ExecutionResult with batch execution details
|
|
160
|
+
"""
|
|
161
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
162
|
+
|
|
163
|
+
if prepared_parameters:
|
|
164
|
+
parameter_sets = cast("list[Sequence[object]]", prepared_parameters)
|
|
165
|
+
await cursor.executemany(sql, parameter_sets)
|
|
166
|
+
|
|
167
|
+
affected_rows = len(parameter_sets)
|
|
168
|
+
else:
|
|
169
|
+
affected_rows = 0
|
|
170
|
+
|
|
171
|
+
return self.create_execution_result(cursor, rowcount_override=affected_rows, is_many_result=True)
|
|
172
|
+
|
|
173
|
+
async def dispatch_execute_script(self, cursor: "AsyncpgConnection", statement: "SQL") -> "ExecutionResult":
|
|
174
|
+
"""Execute SQL script with statement splitting and parameter handling.
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
cursor: AsyncPG connection object
|
|
178
|
+
statement: SQL statement containing multiple statements
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
ExecutionResult with script execution details
|
|
182
|
+
"""
|
|
183
|
+
sql, _ = self._get_compiled_sql(statement, self.statement_config)
|
|
184
|
+
statements = self.split_script_statements(sql, statement.statement_config, strip_trailing_semicolon=True)
|
|
185
|
+
|
|
186
|
+
successful_count = 0
|
|
187
|
+
last_result = None
|
|
188
|
+
|
|
189
|
+
for stmt in statements:
|
|
190
|
+
result = await cursor.execute(stmt)
|
|
191
|
+
last_result = result
|
|
192
|
+
successful_count += 1
|
|
193
|
+
|
|
194
|
+
return self.create_execution_result(
|
|
195
|
+
last_result, statement_count=len(statements), successful_statements=successful_count, is_script_result=True
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
async def dispatch_special_handling(self, cursor: "AsyncpgConnection", statement: "SQL") -> "SQLResult | None":
|
|
199
|
+
"""Handle PostgreSQL COPY operations and other special cases.
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
cursor: AsyncPG connection object
|
|
203
|
+
statement: SQL statement to analyze
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
SQLResult if special operation was handled, None for standard execution
|
|
207
|
+
"""
|
|
208
|
+
if is_copy_operation(statement.operation_type):
|
|
209
|
+
await self._handle_copy_operation(cursor, statement)
|
|
210
|
+
return self.build_statement_result(statement, self.create_execution_result(cursor))
|
|
211
|
+
|
|
212
|
+
return None
|
|
213
|
+
|
|
214
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
215
|
+
# TRANSACTION MANAGEMENT
|
|
216
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
217
|
+
|
|
218
|
+
async def begin(self) -> None:
|
|
219
|
+
"""Begin a database transaction."""
|
|
220
|
+
try:
|
|
221
|
+
await self.connection.execute("BEGIN")
|
|
222
|
+
except asyncpg.PostgresError as e:
|
|
223
|
+
msg = f"Failed to begin async transaction: {e}"
|
|
224
|
+
raise SQLSpecError(msg) from e
|
|
225
|
+
|
|
226
|
+
async def commit(self) -> None:
|
|
227
|
+
"""Commit the current transaction."""
|
|
228
|
+
try:
|
|
229
|
+
await self.connection.execute("COMMIT")
|
|
230
|
+
except asyncpg.PostgresError as e:
|
|
231
|
+
msg = f"Failed to commit async transaction: {e}"
|
|
232
|
+
raise SQLSpecError(msg) from e
|
|
233
|
+
|
|
234
|
+
async def rollback(self) -> None:
|
|
235
|
+
"""Rollback the current transaction."""
|
|
236
|
+
try:
|
|
237
|
+
await self.connection.execute("ROLLBACK")
|
|
238
|
+
except asyncpg.PostgresError as e:
|
|
239
|
+
msg = f"Failed to rollback async transaction: {e}"
|
|
240
|
+
raise SQLSpecError(msg) from e
|
|
241
|
+
|
|
242
|
+
def with_cursor(self, connection: "AsyncpgConnection") -> "AsyncpgCursor":
|
|
243
|
+
"""Create context manager for AsyncPG cursor."""
|
|
244
|
+
return AsyncpgCursor(connection)
|
|
245
|
+
|
|
246
|
+
def handle_database_exceptions(self) -> "AsyncpgExceptionHandler":
|
|
247
|
+
"""Handle database exceptions with PostgreSQL error codes."""
|
|
248
|
+
return AsyncpgExceptionHandler()
|
|
249
|
+
|
|
250
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
251
|
+
# STACK EXECUTION METHODS
|
|
252
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
253
|
+
|
|
254
|
+
async def execute_stack(
|
|
255
|
+
self, stack: "StatementStack", *, continue_on_error: bool = False
|
|
256
|
+
) -> "tuple[StackResult, ...]":
|
|
257
|
+
"""Execute a StatementStack using asyncpg's rapid batching."""
|
|
258
|
+
|
|
259
|
+
if not isinstance(stack, StatementStack) or not stack or self.stack_native_disabled:
|
|
260
|
+
return await super().execute_stack(stack, continue_on_error=continue_on_error)
|
|
261
|
+
|
|
262
|
+
return await self._execute_stack_native(stack, continue_on_error=continue_on_error)
|
|
263
|
+
|
|
264
|
+
async def _execute_stack_native(
|
|
265
|
+
self, stack: "StatementStack", *, continue_on_error: bool
|
|
266
|
+
) -> "tuple[StackResult, ...]":
|
|
267
|
+
results: list[StackResult] = []
|
|
268
|
+
|
|
269
|
+
transaction_cm = None
|
|
270
|
+
if not continue_on_error and not self._connection_in_transaction():
|
|
271
|
+
transaction_cm = self.connection.transaction()
|
|
272
|
+
|
|
273
|
+
with StackExecutionObserver(self, stack, continue_on_error, native_pipeline=True) as observer:
|
|
274
|
+
if transaction_cm is not None:
|
|
275
|
+
async with transaction_cm:
|
|
276
|
+
await self._run_stack_operations(stack, continue_on_error, observer, results)
|
|
277
|
+
else:
|
|
278
|
+
await self._run_stack_operations(stack, continue_on_error, observer, results)
|
|
279
|
+
|
|
280
|
+
return tuple(results)
|
|
281
|
+
|
|
282
|
+
async def _run_stack_operations(
|
|
283
|
+
self,
|
|
284
|
+
stack: "StatementStack",
|
|
285
|
+
continue_on_error: bool,
|
|
286
|
+
observer: "StackExecutionObserver",
|
|
287
|
+
results: "list[StackResult]",
|
|
288
|
+
) -> None:
|
|
289
|
+
"""Run operations for statement stack execution.
|
|
290
|
+
|
|
291
|
+
Extracted from _execute_stack_native to avoid closure compilation issues.
|
|
292
|
+
"""
|
|
293
|
+
for index, operation in enumerate(stack.operations):
|
|
294
|
+
try:
|
|
295
|
+
normalized: NormalizedStackOperation | None = None
|
|
296
|
+
if operation.method == "execute":
|
|
297
|
+
kwargs = dict(operation.keyword_arguments) if operation.keyword_arguments else {}
|
|
298
|
+
statement_config = kwargs.pop("statement_config", None)
|
|
299
|
+
config = statement_config or self.statement_config
|
|
300
|
+
|
|
301
|
+
sql_statement = self.prepare_statement(
|
|
302
|
+
operation.statement, operation.arguments, statement_config=config, kwargs=kwargs
|
|
303
|
+
)
|
|
304
|
+
if not sql_statement.is_script and not sql_statement.is_many:
|
|
305
|
+
sql_text, prepared_parameters = self._get_compiled_sql(sql_statement, config)
|
|
306
|
+
prepared_parameters = cast("tuple[Any, ...] | dict[str, Any] | None", prepared_parameters)
|
|
307
|
+
normalized = NormalizedStackOperation(
|
|
308
|
+
operation=operation, statement=sql_statement, sql=sql_text, parameters=prepared_parameters
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
if normalized is not None:
|
|
312
|
+
stack_result = await self._execute_stack_operation_prepared(normalized)
|
|
313
|
+
else:
|
|
314
|
+
result = await self._execute_stack_operation(operation)
|
|
315
|
+
stack_result = StackResult(result=result)
|
|
316
|
+
except Exception as exc:
|
|
317
|
+
stack_error = StackExecutionError(
|
|
318
|
+
index,
|
|
319
|
+
describe_stack_statement(operation.statement),
|
|
320
|
+
exc,
|
|
321
|
+
adapter=type(self).__name__,
|
|
322
|
+
mode="continue-on-error" if continue_on_error else "fail-fast",
|
|
323
|
+
)
|
|
324
|
+
if continue_on_error:
|
|
325
|
+
observer.record_operation_error(stack_error)
|
|
326
|
+
results.append(StackResult.from_error(stack_error))
|
|
327
|
+
continue
|
|
328
|
+
raise stack_error from exc
|
|
329
|
+
|
|
330
|
+
results.append(stack_result)
|
|
331
|
+
|
|
332
|
+
async def _execute_stack_operation_prepared(self, normalized: "NormalizedStackOperation") -> StackResult:
|
|
333
|
+
prepared = await self._get_prepared_statement(normalized.sql)
|
|
334
|
+
metadata = {"prepared_statement": True}
|
|
335
|
+
|
|
336
|
+
if normalized.statement.returns_rows():
|
|
337
|
+
rows = await invoke_prepared_statement(prepared, normalized.parameters, fetch=True)
|
|
338
|
+
data, _ = collect_rows(rows)
|
|
339
|
+
sql_result = create_sql_result(normalized.statement, data=data, rows_affected=len(data), metadata=metadata)
|
|
340
|
+
return StackResult.from_sql_result(sql_result)
|
|
341
|
+
|
|
342
|
+
status = await invoke_prepared_statement(prepared, normalized.parameters, fetch=False)
|
|
343
|
+
rowcount = parse_status(status)
|
|
344
|
+
sql_result = create_sql_result(normalized.statement, rows_affected=rowcount, metadata=metadata)
|
|
345
|
+
return StackResult.from_sql_result(sql_result)
|
|
346
|
+
|
|
347
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
348
|
+
# STORAGE API METHODS
|
|
349
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
350
|
+
|
|
351
|
+
async def select_to_storage(
|
|
352
|
+
self,
|
|
353
|
+
statement: "SQL | str",
|
|
354
|
+
destination: "StorageDestination",
|
|
355
|
+
/,
|
|
356
|
+
*parameters: Any,
|
|
357
|
+
statement_config: "StatementConfig | None" = None,
|
|
358
|
+
partitioner: "dict[str, object] | None" = None,
|
|
359
|
+
format_hint: "StorageFormat | None" = None,
|
|
360
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
361
|
+
**kwargs: Any,
|
|
362
|
+
) -> "StorageBridgeJob":
|
|
363
|
+
"""Execute a query and persist results to storage once native COPY is available."""
|
|
364
|
+
|
|
365
|
+
self._require_capability("arrow_export_enabled")
|
|
366
|
+
arrow_result = await self.select_to_arrow(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
367
|
+
async_pipeline = self._storage_pipeline()
|
|
368
|
+
telemetry_payload = await self._write_result_to_storage_async(
|
|
369
|
+
arrow_result, destination, format_hint=format_hint, pipeline=async_pipeline
|
|
370
|
+
)
|
|
371
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
372
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
373
|
+
|
|
374
|
+
async def load_from_arrow(
|
|
375
|
+
self,
|
|
376
|
+
table: str,
|
|
377
|
+
source: "ArrowResult | Any",
|
|
378
|
+
*,
|
|
379
|
+
partitioner: "dict[str, object] | None" = None,
|
|
380
|
+
overwrite: bool = False,
|
|
381
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
382
|
+
) -> "StorageBridgeJob":
|
|
383
|
+
"""Load Arrow data into a PostgreSQL table via COPY."""
|
|
384
|
+
|
|
385
|
+
self._require_capability("arrow_import_enabled")
|
|
386
|
+
arrow_table = self._coerce_arrow_table(source)
|
|
387
|
+
if overwrite:
|
|
388
|
+
try:
|
|
389
|
+
await self.connection.execute(f"TRUNCATE TABLE {table}")
|
|
390
|
+
except asyncpg.PostgresError as exc:
|
|
391
|
+
msg = f"Failed to truncate table '{table}': {exc}"
|
|
392
|
+
raise SQLSpecError(msg) from exc
|
|
393
|
+
columns, records = self._arrow_table_to_rows(arrow_table)
|
|
394
|
+
if records:
|
|
395
|
+
await self.connection.copy_records_to_table(table, records=records, columns=columns)
|
|
396
|
+
telemetry_payload = self._build_ingest_telemetry(arrow_table)
|
|
397
|
+
telemetry_payload["destination"] = table
|
|
398
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
399
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
400
|
+
|
|
401
|
+
async def load_from_storage(
|
|
402
|
+
self,
|
|
403
|
+
table: str,
|
|
404
|
+
source: "StorageDestination",
|
|
405
|
+
*,
|
|
406
|
+
file_format: "StorageFormat",
|
|
407
|
+
partitioner: "dict[str, object] | None" = None,
|
|
408
|
+
overwrite: bool = False,
|
|
409
|
+
) -> "StorageBridgeJob":
|
|
410
|
+
"""Read an artifact from storage and ingest it via COPY."""
|
|
411
|
+
|
|
412
|
+
arrow_table, inbound = await self._read_arrow_from_storage_async(source, file_format=file_format)
|
|
413
|
+
return await self.load_from_arrow(
|
|
414
|
+
table, arrow_table, partitioner=partitioner, overwrite=overwrite, telemetry=inbound
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
418
|
+
# UTILITY METHODS
|
|
419
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
420
|
+
|
|
421
|
+
@property
|
|
422
|
+
def data_dictionary(self) -> "AsyncpgDataDictionary":
|
|
423
|
+
"""Get the data dictionary for this driver.
|
|
424
|
+
|
|
425
|
+
Returns:
|
|
426
|
+
Data dictionary instance for metadata queries
|
|
427
|
+
"""
|
|
428
|
+
if self._data_dictionary is None:
|
|
429
|
+
self._data_dictionary = AsyncpgDataDictionary()
|
|
430
|
+
return self._data_dictionary
|
|
431
|
+
|
|
432
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
433
|
+
# PRIVATE/INTERNAL METHODS
|
|
434
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
435
|
+
|
|
436
|
+
def _connection_in_transaction(self) -> bool:
|
|
437
|
+
"""Check if connection is in transaction."""
|
|
438
|
+
return bool(self.connection.is_in_transaction())
|
|
439
|
+
|
|
440
|
+
async def _get_prepared_statement(self, sql: str) -> "AsyncpgPreparedStatement":
|
|
441
|
+
cached = self._prepared_statements.get(sql)
|
|
442
|
+
if cached is not None:
|
|
443
|
+
self._prepared_statements.move_to_end(sql)
|
|
444
|
+
return cached
|
|
445
|
+
|
|
446
|
+
prepared = cast("AsyncpgPreparedStatement", await self.connection.prepare(sql))
|
|
447
|
+
self._prepared_statements[sql] = prepared
|
|
448
|
+
if len(self._prepared_statements) > PREPARED_STATEMENT_CACHE_SIZE:
|
|
449
|
+
self._prepared_statements.popitem(last=False)
|
|
450
|
+
return prepared
|
|
451
|
+
|
|
452
|
+
async def _handle_copy_operation(self, cursor: "AsyncpgConnection", statement: "SQL") -> None:
|
|
453
|
+
"""Handle PostgreSQL COPY operations.
|
|
454
|
+
|
|
455
|
+
Supports both COPY FROM STDIN and COPY TO STDOUT operations.
|
|
456
|
+
|
|
457
|
+
Args:
|
|
458
|
+
cursor: AsyncPG connection object
|
|
459
|
+
statement: SQL statement with COPY operation
|
|
460
|
+
"""
|
|
461
|
+
|
|
462
|
+
execution_args = statement.statement_config.execution_args
|
|
463
|
+
metadata: dict[str, Any] = dict(execution_args) if execution_args else {}
|
|
464
|
+
sql_text, _ = self._get_compiled_sql(statement, statement.statement_config)
|
|
465
|
+
sql_upper = sql_text.upper()
|
|
466
|
+
copy_data = metadata.get("postgres_copy_data")
|
|
467
|
+
|
|
468
|
+
if copy_data and is_copy_from_operation(statement.operation_type) and "FROM STDIN" in sql_upper:
|
|
469
|
+
if isinstance(copy_data, dict):
|
|
470
|
+
data_str = (
|
|
471
|
+
str(next(iter(copy_data.values())))
|
|
472
|
+
if len(copy_data) == 1
|
|
473
|
+
else "\n".join(str(value) for value in copy_data.values())
|
|
474
|
+
)
|
|
475
|
+
elif isinstance(copy_data, (list, tuple)):
|
|
476
|
+
data_str = str(copy_data[0]) if len(copy_data) == 1 else "\n".join(str(value) for value in copy_data)
|
|
477
|
+
else:
|
|
478
|
+
data_str = str(copy_data)
|
|
479
|
+
|
|
480
|
+
data_io = BytesIO(data_str.encode("utf-8"))
|
|
481
|
+
await cursor.copy_from_query(sql_text, output=data_io)
|
|
482
|
+
return
|
|
483
|
+
|
|
484
|
+
await cursor.execute(sql_text)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
register_driver_profile("asyncpg", driver_profile)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Events helpers for the asyncpg adapter."""
|
|
2
|
+
|
|
3
|
+
from sqlspec.adapters.asyncpg.events.backend import AsyncpgEventsBackend, create_event_backend
|
|
4
|
+
from sqlspec.adapters.asyncpg.events.store import AsyncpgEventQueueStore
|
|
5
|
+
|
|
6
|
+
__all__ = ("AsyncpgEventQueueStore", "AsyncpgEventsBackend", "create_event_backend")
|