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,208 @@
|
|
|
1
|
+
"""SQLite-specific data dictionary for metadata queries via aiosqlite."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, ClassVar
|
|
4
|
+
|
|
5
|
+
from mypy_extensions import mypyc_attr
|
|
6
|
+
|
|
7
|
+
from sqlspec.adapters.aiosqlite.core import format_identifier
|
|
8
|
+
from sqlspec.data_dictionary import get_dialect_config
|
|
9
|
+
from sqlspec.driver import AsyncDataDictionaryBase
|
|
10
|
+
from sqlspec.typing import ColumnMetadata, ForeignKeyMetadata, IndexMetadata, TableMetadata, VersionInfo
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from sqlspec.adapters.aiosqlite.driver import AiosqliteDriver
|
|
14
|
+
from sqlspec.data_dictionary._types import DialectConfig
|
|
15
|
+
|
|
16
|
+
__all__ = ("AiosqliteDataDictionary",)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@mypyc_attr(allow_interpreted_subclasses=True, native_class=False)
|
|
20
|
+
class AiosqliteDataDictionary(AsyncDataDictionaryBase):
|
|
21
|
+
"""SQLite-specific async data dictionary."""
|
|
22
|
+
|
|
23
|
+
dialect: ClassVar[str] = "sqlite"
|
|
24
|
+
|
|
25
|
+
def __init__(self) -> None:
|
|
26
|
+
super().__init__()
|
|
27
|
+
|
|
28
|
+
def get_dialect_config(self) -> "DialectConfig":
|
|
29
|
+
"""Return the dialect configuration for this data dictionary."""
|
|
30
|
+
return get_dialect_config(type(self).dialect)
|
|
31
|
+
|
|
32
|
+
def resolve_schema(self, schema: "str | None") -> "str | None":
|
|
33
|
+
"""Return a schema name using dialect defaults when missing."""
|
|
34
|
+
if schema is not None:
|
|
35
|
+
return schema
|
|
36
|
+
return self.get_dialect_config().default_schema
|
|
37
|
+
|
|
38
|
+
def list_available_features(self) -> "list[str]":
|
|
39
|
+
"""List available feature flags for this dialect."""
|
|
40
|
+
config = self.get_dialect_config()
|
|
41
|
+
features = {"supports_transactions", "supports_prepared_statements"}
|
|
42
|
+
features.update(config.feature_flags.keys())
|
|
43
|
+
features.update(config.feature_versions.keys())
|
|
44
|
+
return sorted(features)
|
|
45
|
+
|
|
46
|
+
async def get_version(self, driver: "AiosqliteDriver") -> "VersionInfo | None":
|
|
47
|
+
"""Get SQLite database version information.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
driver: Async database driver instance.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
SQLite version information or None if detection fails.
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
driver_id = id(driver)
|
|
57
|
+
# Inline cache check to avoid cross-module method call that causes mypyc segfault
|
|
58
|
+
if driver_id in self._version_fetch_attempted:
|
|
59
|
+
return self._version_cache.get(driver_id)
|
|
60
|
+
# Not cached, fetch from database
|
|
61
|
+
|
|
62
|
+
version_value = await driver.select_value_or_none(self.get_query("version"))
|
|
63
|
+
if not version_value:
|
|
64
|
+
self._log_version_unavailable(type(self).dialect, "missing")
|
|
65
|
+
self.cache_version(driver_id, None)
|
|
66
|
+
return None
|
|
67
|
+
|
|
68
|
+
version_info = self.parse_version_with_pattern(self.get_dialect_config().version_pattern, str(version_value))
|
|
69
|
+
if version_info is None:
|
|
70
|
+
self._log_version_unavailable(type(self).dialect, "parse_failed")
|
|
71
|
+
self.cache_version(driver_id, None)
|
|
72
|
+
return None
|
|
73
|
+
|
|
74
|
+
self._log_version_detected(type(self).dialect, version_info)
|
|
75
|
+
self.cache_version(driver_id, version_info)
|
|
76
|
+
return version_info
|
|
77
|
+
|
|
78
|
+
async def get_feature_flag(self, driver: "AiosqliteDriver", feature: str) -> bool:
|
|
79
|
+
"""Check if SQLite database supports a specific feature.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
driver: Async database driver instance.
|
|
83
|
+
feature: Feature name to check.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
True if feature is supported, False otherwise.
|
|
87
|
+
|
|
88
|
+
"""
|
|
89
|
+
version_info = await self.get_version(driver)
|
|
90
|
+
return self.resolve_feature_flag(feature, version_info)
|
|
91
|
+
|
|
92
|
+
async def get_optimal_type(self, driver: "AiosqliteDriver", type_category: str) -> str:
|
|
93
|
+
"""Get optimal SQLite type for a category.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
driver: Async database driver instance.
|
|
97
|
+
type_category: Type category.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
SQLite-specific type name.
|
|
101
|
+
|
|
102
|
+
"""
|
|
103
|
+
config = self.get_dialect_config()
|
|
104
|
+
version_info = await self.get_version(driver)
|
|
105
|
+
|
|
106
|
+
if type_category == "json":
|
|
107
|
+
json_version = config.get_feature_version("supports_json")
|
|
108
|
+
if version_info and json_version and version_info >= json_version:
|
|
109
|
+
return "JSON"
|
|
110
|
+
return "TEXT"
|
|
111
|
+
|
|
112
|
+
return config.get_optimal_type(type_category)
|
|
113
|
+
|
|
114
|
+
async def get_tables(self, driver: "AiosqliteDriver", schema: "str | None" = None) -> "list[TableMetadata]":
|
|
115
|
+
"""Get tables sorted by topological dependency order using SQLite catalog."""
|
|
116
|
+
schema_name = self.resolve_schema(schema)
|
|
117
|
+
self._log_schema_introspect(driver, schema_name=schema_name, table_name=None, operation="tables")
|
|
118
|
+
schema_prefix = f"{format_identifier(schema_name)}." if schema_name else ""
|
|
119
|
+
query_text = self.get_query_text("tables_by_schema").format(schema_prefix=schema_prefix)
|
|
120
|
+
return await driver.select(query_text, schema_type=TableMetadata)
|
|
121
|
+
|
|
122
|
+
async def get_columns(
|
|
123
|
+
self, driver: "AiosqliteDriver", table: "str | None" = None, schema: "str | None" = None
|
|
124
|
+
) -> "list[ColumnMetadata]":
|
|
125
|
+
"""Get column information for a table or schema."""
|
|
126
|
+
schema_name = self.resolve_schema(schema)
|
|
127
|
+
schema_prefix = f"{format_identifier(schema_name)}." if schema_name else ""
|
|
128
|
+
if table is None:
|
|
129
|
+
self._log_schema_introspect(driver, schema_name=schema_name, table_name=None, operation="columns")
|
|
130
|
+
query_text = self.get_query_text("columns_by_schema").format(schema_prefix=schema_prefix)
|
|
131
|
+
return await driver.select(query_text, schema_type=ColumnMetadata)
|
|
132
|
+
|
|
133
|
+
assert table is not None
|
|
134
|
+
self._log_table_describe(driver, schema_name=schema_name, table_name=table, operation="columns")
|
|
135
|
+
table_name = table
|
|
136
|
+
table_identifier = f"{schema_name}.{table_name}" if schema_name else table_name
|
|
137
|
+
query_text = self.get_query_text("columns_by_table").format(table_name=format_identifier(table_identifier))
|
|
138
|
+
return await driver.select(query_text, schema_type=ColumnMetadata)
|
|
139
|
+
|
|
140
|
+
async def get_indexes(
|
|
141
|
+
self, driver: "AiosqliteDriver", table: "str | None" = None, schema: "str | None" = None
|
|
142
|
+
) -> "list[IndexMetadata]":
|
|
143
|
+
"""Get index metadata for a table or schema."""
|
|
144
|
+
schema_name = self.resolve_schema(schema)
|
|
145
|
+
indexes: list[IndexMetadata] = []
|
|
146
|
+
if table is None:
|
|
147
|
+
self._log_schema_introspect(driver, schema_name=schema_name, table_name=None, operation="indexes")
|
|
148
|
+
for table_info in await self.get_tables(driver, schema=schema_name):
|
|
149
|
+
table_name = table_info.get("table_name")
|
|
150
|
+
if not table_name:
|
|
151
|
+
continue
|
|
152
|
+
indexes.extend(await self.get_indexes(driver, table=table_name, schema=schema_name))
|
|
153
|
+
return indexes
|
|
154
|
+
|
|
155
|
+
assert table is not None
|
|
156
|
+
self._log_table_describe(driver, schema_name=schema_name, table_name=table, operation="indexes")
|
|
157
|
+
table_name = table
|
|
158
|
+
table_identifier = f"{schema_name}.{table_name}" if schema_name else table_name
|
|
159
|
+
index_list_sql = self.get_query_text("indexes_by_table").format(table_name=format_identifier(table_identifier))
|
|
160
|
+
index_rows = await driver.select(index_list_sql)
|
|
161
|
+
for row in index_rows:
|
|
162
|
+
index_name = row.get("name")
|
|
163
|
+
if not index_name:
|
|
164
|
+
continue
|
|
165
|
+
index_identifier = f"{schema_name}.{index_name}" if schema_name else index_name
|
|
166
|
+
columns_sql = self.get_query_text("index_columns_by_index").format(
|
|
167
|
+
index_name=format_identifier(index_identifier)
|
|
168
|
+
)
|
|
169
|
+
columns_rows = await driver.select(columns_sql)
|
|
170
|
+
columns: list[str] = []
|
|
171
|
+
for col in columns_rows:
|
|
172
|
+
column_name = col.get("name")
|
|
173
|
+
if column_name is None:
|
|
174
|
+
continue
|
|
175
|
+
columns.append(str(column_name))
|
|
176
|
+
is_primary = row.get("origin") == "pk"
|
|
177
|
+
index_metadata: IndexMetadata = {
|
|
178
|
+
"index_name": index_name,
|
|
179
|
+
"table_name": table_name,
|
|
180
|
+
"columns": columns,
|
|
181
|
+
"is_primary": is_primary,
|
|
182
|
+
}
|
|
183
|
+
if schema_name is not None:
|
|
184
|
+
index_metadata["schema_name"] = schema_name
|
|
185
|
+
unique_value = row.get("unique")
|
|
186
|
+
if unique_value is not None:
|
|
187
|
+
index_metadata["is_unique"] = unique_value
|
|
188
|
+
indexes.append(index_metadata)
|
|
189
|
+
return indexes
|
|
190
|
+
|
|
191
|
+
async def get_foreign_keys(
|
|
192
|
+
self, driver: "AiosqliteDriver", table: "str | None" = None, schema: "str | None" = None
|
|
193
|
+
) -> "list[ForeignKeyMetadata]":
|
|
194
|
+
"""Get foreign key metadata."""
|
|
195
|
+
schema_name = self.resolve_schema(schema)
|
|
196
|
+
schema_prefix = f"{format_identifier(schema_name)}." if schema_name else ""
|
|
197
|
+
if table is None:
|
|
198
|
+
self._log_schema_introspect(driver, schema_name=schema_name, table_name=None, operation="foreign_keys")
|
|
199
|
+
query_text = self.get_query_text("foreign_keys_by_schema").format(schema_prefix=schema_prefix)
|
|
200
|
+
return await driver.select(query_text, schema_type=ForeignKeyMetadata)
|
|
201
|
+
|
|
202
|
+
self._log_table_describe(driver, schema_name=schema_name, table_name=table, operation="foreign_keys")
|
|
203
|
+
table_label = table.replace("'", "''")
|
|
204
|
+
table_identifier = f"{schema_name}.{table}" if schema_name else table
|
|
205
|
+
query_text = self.get_query_text("foreign_keys_by_table").format(
|
|
206
|
+
table_name=format_identifier(table_identifier), table_label=table_label
|
|
207
|
+
)
|
|
208
|
+
return await driver.select(query_text, schema_type=ForeignKeyMetadata)
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"""AIOSQLite driver implementation for async SQLite operations."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import contextlib
|
|
5
|
+
import random
|
|
6
|
+
import sqlite3
|
|
7
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
8
|
+
|
|
9
|
+
import aiosqlite
|
|
10
|
+
|
|
11
|
+
from sqlspec.adapters.aiosqlite.core import (
|
|
12
|
+
build_insert_statement,
|
|
13
|
+
collect_rows,
|
|
14
|
+
create_mapped_exception,
|
|
15
|
+
default_statement_config,
|
|
16
|
+
driver_profile,
|
|
17
|
+
format_identifier,
|
|
18
|
+
normalize_execute_many_parameters,
|
|
19
|
+
normalize_execute_parameters,
|
|
20
|
+
resolve_rowcount,
|
|
21
|
+
)
|
|
22
|
+
from sqlspec.adapters.aiosqlite.data_dictionary import AiosqliteDataDictionary
|
|
23
|
+
from sqlspec.core import ArrowResult, get_cache_config, register_driver_profile
|
|
24
|
+
from sqlspec.driver import AsyncDriverAdapterBase
|
|
25
|
+
from sqlspec.exceptions import SQLSpecError
|
|
26
|
+
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
from sqlspec.adapters.aiosqlite._typing import AiosqliteConnection
|
|
29
|
+
from sqlspec.core import SQL, StatementConfig
|
|
30
|
+
from sqlspec.driver import ExecutionResult
|
|
31
|
+
from sqlspec.storage import StorageBridgeJob, StorageDestination, StorageFormat, StorageTelemetry
|
|
32
|
+
|
|
33
|
+
from sqlspec.adapters.aiosqlite._typing import AiosqliteSessionContext
|
|
34
|
+
|
|
35
|
+
__all__ = ("AiosqliteCursor", "AiosqliteDriver", "AiosqliteExceptionHandler", "AiosqliteSessionContext")
|
|
36
|
+
|
|
37
|
+
SQLITE_CONSTRAINT_UNIQUE_CODE = 2067
|
|
38
|
+
SQLITE_CONSTRAINT_FOREIGNKEY_CODE = 787
|
|
39
|
+
SQLITE_CONSTRAINT_NOTNULL_CODE = 1811
|
|
40
|
+
SQLITE_CONSTRAINT_CHECK_CODE = 531
|
|
41
|
+
SQLITE_CONSTRAINT_CODE = 19
|
|
42
|
+
SQLITE_CANTOPEN_CODE = 14
|
|
43
|
+
SQLITE_IOERR_CODE = 10
|
|
44
|
+
SQLITE_MISMATCH_CODE = 20
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class AiosqliteCursor:
|
|
48
|
+
"""Async context manager for AIOSQLite cursors."""
|
|
49
|
+
|
|
50
|
+
__slots__ = ("connection", "cursor")
|
|
51
|
+
|
|
52
|
+
def __init__(self, connection: "AiosqliteConnection") -> None:
|
|
53
|
+
self.connection = connection
|
|
54
|
+
self.cursor: aiosqlite.Cursor | None = None
|
|
55
|
+
|
|
56
|
+
async def __aenter__(self) -> "aiosqlite.Cursor":
|
|
57
|
+
self.cursor = await self.connection.cursor()
|
|
58
|
+
return self.cursor
|
|
59
|
+
|
|
60
|
+
async def __aexit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: Any) -> None:
|
|
61
|
+
if exc_type is not None:
|
|
62
|
+
return
|
|
63
|
+
if self.cursor is not None:
|
|
64
|
+
with contextlib.suppress(Exception):
|
|
65
|
+
await self.cursor.close()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class AiosqliteExceptionHandler:
|
|
69
|
+
"""Async context manager for handling aiosqlite database exceptions.
|
|
70
|
+
|
|
71
|
+
Maps SQLite extended result codes to specific SQLSpec exceptions
|
|
72
|
+
for better error handling in application code.
|
|
73
|
+
|
|
74
|
+
Uses deferred exception pattern for mypyc compatibility: exceptions
|
|
75
|
+
are stored in pending_exception rather than raised from __aexit__
|
|
76
|
+
to avoid ABI boundary violations with compiled code.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
__slots__ = ("pending_exception",)
|
|
80
|
+
|
|
81
|
+
def __init__(self) -> None:
|
|
82
|
+
self.pending_exception: Exception | None = None
|
|
83
|
+
|
|
84
|
+
async def __aenter__(self) -> "AiosqliteExceptionHandler":
|
|
85
|
+
return self
|
|
86
|
+
|
|
87
|
+
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:
|
|
88
|
+
if exc_val is None:
|
|
89
|
+
return False
|
|
90
|
+
if isinstance(exc_val, (aiosqlite.Error, sqlite3.Error)):
|
|
91
|
+
self.pending_exception = create_mapped_exception(exc_val)
|
|
92
|
+
return True
|
|
93
|
+
return False
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AiosqliteDriver(AsyncDriverAdapterBase):
|
|
97
|
+
"""AIOSQLite driver for async SQLite database operations."""
|
|
98
|
+
|
|
99
|
+
__slots__ = ("_data_dictionary",)
|
|
100
|
+
dialect = "sqlite"
|
|
101
|
+
|
|
102
|
+
def __init__(
|
|
103
|
+
self,
|
|
104
|
+
connection: "AiosqliteConnection",
|
|
105
|
+
statement_config: "StatementConfig | None" = None,
|
|
106
|
+
driver_features: "dict[str, Any] | None" = None,
|
|
107
|
+
) -> None:
|
|
108
|
+
if statement_config is None:
|
|
109
|
+
statement_config = default_statement_config.replace(
|
|
110
|
+
enable_caching=get_cache_config().compiled_cache_enabled
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
super().__init__(connection=connection, statement_config=statement_config, driver_features=driver_features)
|
|
114
|
+
self._data_dictionary: AiosqliteDataDictionary | None = None
|
|
115
|
+
|
|
116
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
117
|
+
# CORE DISPATCH METHODS
|
|
118
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
119
|
+
|
|
120
|
+
async def dispatch_execute(self, cursor: "aiosqlite.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
121
|
+
"""Execute single SQL statement."""
|
|
122
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
123
|
+
await cursor.execute(sql, normalize_execute_parameters(prepared_parameters))
|
|
124
|
+
|
|
125
|
+
if statement.returns_rows():
|
|
126
|
+
fetched_data = await cursor.fetchall()
|
|
127
|
+
|
|
128
|
+
# aiosqlite returns Iterable[Row], core helper expects Iterable[Any]
|
|
129
|
+
# Use cast to satisfy mypy and pyright
|
|
130
|
+
data, column_names, row_count = collect_rows(cast("list[Any]", fetched_data), cursor.description)
|
|
131
|
+
|
|
132
|
+
return self.create_execution_result(
|
|
133
|
+
cursor, selected_data=data, column_names=column_names, data_row_count=row_count, is_select_result=True
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
affected_rows = resolve_rowcount(cursor)
|
|
137
|
+
return self.create_execution_result(cursor, rowcount_override=affected_rows)
|
|
138
|
+
|
|
139
|
+
async def dispatch_execute_many(self, cursor: "aiosqlite.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
140
|
+
"""Execute SQL with multiple parameter sets."""
|
|
141
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
142
|
+
|
|
143
|
+
await cursor.executemany(sql, normalize_execute_many_parameters(prepared_parameters))
|
|
144
|
+
|
|
145
|
+
affected_rows = resolve_rowcount(cursor)
|
|
146
|
+
|
|
147
|
+
return self.create_execution_result(cursor, rowcount_override=affected_rows, is_many_result=True)
|
|
148
|
+
|
|
149
|
+
async def dispatch_execute_script(self, cursor: "aiosqlite.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
150
|
+
"""Execute SQL script."""
|
|
151
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
152
|
+
statements = self.split_script_statements(sql, statement.statement_config, strip_trailing_semicolon=True)
|
|
153
|
+
|
|
154
|
+
successful_count = 0
|
|
155
|
+
last_cursor = cursor
|
|
156
|
+
|
|
157
|
+
for stmt in statements:
|
|
158
|
+
await cursor.execute(stmt, normalize_execute_parameters(prepared_parameters))
|
|
159
|
+
successful_count += 1
|
|
160
|
+
|
|
161
|
+
return self.create_execution_result(
|
|
162
|
+
last_cursor, statement_count=len(statements), successful_statements=successful_count, is_script_result=True
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
166
|
+
# TRANSACTION MANAGEMENT
|
|
167
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
168
|
+
|
|
169
|
+
async def begin(self) -> None:
|
|
170
|
+
"""Begin a database transaction."""
|
|
171
|
+
try:
|
|
172
|
+
if not self.connection.in_transaction:
|
|
173
|
+
await self.connection.execute("BEGIN IMMEDIATE")
|
|
174
|
+
except aiosqlite.Error as e:
|
|
175
|
+
max_retries = 3
|
|
176
|
+
for attempt in range(max_retries):
|
|
177
|
+
delay = 0.01 * (2**attempt) + random.uniform(0, 0.01) # noqa: S311
|
|
178
|
+
await asyncio.sleep(delay)
|
|
179
|
+
try:
|
|
180
|
+
await self.connection.execute("BEGIN IMMEDIATE")
|
|
181
|
+
except aiosqlite.Error:
|
|
182
|
+
if attempt == max_retries - 1:
|
|
183
|
+
break
|
|
184
|
+
else:
|
|
185
|
+
return
|
|
186
|
+
msg = f"Failed to begin transaction after retries: {e}"
|
|
187
|
+
raise SQLSpecError(msg) from e
|
|
188
|
+
|
|
189
|
+
async def commit(self) -> None:
|
|
190
|
+
"""Commit the current transaction."""
|
|
191
|
+
try:
|
|
192
|
+
await self.connection.commit()
|
|
193
|
+
except aiosqlite.Error as e:
|
|
194
|
+
msg = f"Failed to commit transaction: {e}"
|
|
195
|
+
raise SQLSpecError(msg) from e
|
|
196
|
+
|
|
197
|
+
async def rollback(self) -> None:
|
|
198
|
+
"""Rollback the current transaction."""
|
|
199
|
+
try:
|
|
200
|
+
await self.connection.rollback()
|
|
201
|
+
except aiosqlite.Error as e:
|
|
202
|
+
msg = f"Failed to rollback transaction: {e}"
|
|
203
|
+
raise SQLSpecError(msg) from e
|
|
204
|
+
|
|
205
|
+
def with_cursor(self, connection: "AiosqliteConnection") -> "AiosqliteCursor":
|
|
206
|
+
"""Create async context manager for AIOSQLite cursor."""
|
|
207
|
+
return AiosqliteCursor(connection)
|
|
208
|
+
|
|
209
|
+
def handle_database_exceptions(self) -> "AiosqliteExceptionHandler":
|
|
210
|
+
"""Handle AIOSQLite-specific exceptions."""
|
|
211
|
+
return AiosqliteExceptionHandler()
|
|
212
|
+
|
|
213
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
214
|
+
# STORAGE API METHODS
|
|
215
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
216
|
+
|
|
217
|
+
async def select_to_storage(
|
|
218
|
+
self,
|
|
219
|
+
statement: "SQL | str",
|
|
220
|
+
destination: "StorageDestination",
|
|
221
|
+
/,
|
|
222
|
+
*parameters: Any,
|
|
223
|
+
statement_config: "StatementConfig | None" = None,
|
|
224
|
+
partitioner: "dict[str, object] | None" = None,
|
|
225
|
+
format_hint: "StorageFormat | None" = None,
|
|
226
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
227
|
+
**kwargs: Any,
|
|
228
|
+
) -> "StorageBridgeJob":
|
|
229
|
+
"""Execute a query and stream Arrow results into storage."""
|
|
230
|
+
|
|
231
|
+
self._require_capability("arrow_export_enabled")
|
|
232
|
+
arrow_result = await self.select_to_arrow(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
233
|
+
async_pipeline = self._storage_pipeline()
|
|
234
|
+
telemetry_payload = await self._write_result_to_storage_async(
|
|
235
|
+
arrow_result, destination, format_hint=format_hint, pipeline=async_pipeline
|
|
236
|
+
)
|
|
237
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
238
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
239
|
+
|
|
240
|
+
async def load_from_arrow(
|
|
241
|
+
self,
|
|
242
|
+
table: str,
|
|
243
|
+
source: "ArrowResult | Any",
|
|
244
|
+
*,
|
|
245
|
+
partitioner: "dict[str, object] | None" = None,
|
|
246
|
+
overwrite: bool = False,
|
|
247
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
248
|
+
) -> "StorageBridgeJob":
|
|
249
|
+
"""Load Arrow data into SQLite using batched inserts."""
|
|
250
|
+
|
|
251
|
+
self._require_capability("arrow_import_enabled")
|
|
252
|
+
arrow_table = self._coerce_arrow_table(source)
|
|
253
|
+
if overwrite:
|
|
254
|
+
statement = f"DELETE FROM {format_identifier(table)}"
|
|
255
|
+
async with self.handle_database_exceptions(), self.with_cursor(self.connection) as cursor:
|
|
256
|
+
await cursor.execute(statement)
|
|
257
|
+
|
|
258
|
+
columns, records = self._arrow_table_to_rows(arrow_table)
|
|
259
|
+
if records:
|
|
260
|
+
insert_sql = build_insert_statement(table, columns)
|
|
261
|
+
async with self.handle_database_exceptions(), self.with_cursor(self.connection) as cursor:
|
|
262
|
+
await cursor.executemany(insert_sql, records)
|
|
263
|
+
|
|
264
|
+
telemetry_payload = self._build_ingest_telemetry(arrow_table)
|
|
265
|
+
telemetry_payload["destination"] = table
|
|
266
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
267
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
268
|
+
|
|
269
|
+
async def load_from_storage(
|
|
270
|
+
self,
|
|
271
|
+
table: str,
|
|
272
|
+
source: "StorageDestination",
|
|
273
|
+
*,
|
|
274
|
+
file_format: "StorageFormat",
|
|
275
|
+
partitioner: "dict[str, object] | None" = None,
|
|
276
|
+
overwrite: bool = False,
|
|
277
|
+
) -> "StorageBridgeJob":
|
|
278
|
+
"""Load staged artifacts from storage into SQLite."""
|
|
279
|
+
|
|
280
|
+
arrow_table, inbound = await self._read_arrow_from_storage_async(source, file_format=file_format)
|
|
281
|
+
return await self.load_from_arrow(
|
|
282
|
+
table, arrow_table, partitioner=partitioner, overwrite=overwrite, telemetry=inbound
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
286
|
+
# UTILITY METHODS
|
|
287
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
288
|
+
|
|
289
|
+
@property
|
|
290
|
+
def data_dictionary(self) -> "AiosqliteDataDictionary":
|
|
291
|
+
"""Get the data dictionary for this driver.
|
|
292
|
+
|
|
293
|
+
Returns:
|
|
294
|
+
Data dictionary instance for metadata queries
|
|
295
|
+
"""
|
|
296
|
+
if self._data_dictionary is None:
|
|
297
|
+
self._data_dictionary = AiosqliteDataDictionary()
|
|
298
|
+
return self._data_dictionary
|
|
299
|
+
|
|
300
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
301
|
+
# PRIVATE/INTERNAL METHODS
|
|
302
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
303
|
+
|
|
304
|
+
def _connection_in_transaction(self) -> bool:
|
|
305
|
+
"""Check if connection is in transaction.
|
|
306
|
+
|
|
307
|
+
Returns:
|
|
308
|
+
True if connection is in an active transaction.
|
|
309
|
+
"""
|
|
310
|
+
return bool(self.connection.in_transaction)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
register_driver_profile("aiosqlite", driver_profile)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""AioSQLite event queue store."""
|
|
2
|
+
|
|
3
|
+
from sqlspec.adapters.aiosqlite.config import AiosqliteConfig
|
|
4
|
+
from sqlspec.extensions.events import BaseEventQueueStore
|
|
5
|
+
|
|
6
|
+
__all__ = ("AiosqliteEventQueueStore",)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AiosqliteEventQueueStore(BaseEventQueueStore[AiosqliteConfig]):
|
|
10
|
+
"""Provide column definitions for the async SQLite adapter.
|
|
11
|
+
|
|
12
|
+
SQLite stores JSON as TEXT since it lacks a native JSON column type.
|
|
13
|
+
JSON functions can still operate on TEXT columns containing valid JSON.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
__slots__ = ()
|
|
17
|
+
|
|
18
|
+
def _column_types(self) -> "tuple[str, str, str]":
|
|
19
|
+
"""Return SQLite-compatible column types for the event queue."""
|
|
20
|
+
return "TEXT", "TEXT", "TIMESTAMP"
|