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,134 @@
|
|
|
1
|
+
"""Correlation ID tracking for distributed tracing.
|
|
2
|
+
|
|
3
|
+
This module provides utilities for tracking correlation IDs across
|
|
4
|
+
database operations, enabling distributed tracing and debugging.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import uuid
|
|
8
|
+
from collections.abc import Generator, MutableMapping
|
|
9
|
+
from contextlib import contextmanager
|
|
10
|
+
from contextvars import ContextVar
|
|
11
|
+
from logging import Logger, LoggerAdapter
|
|
12
|
+
from typing import Any, ClassVar
|
|
13
|
+
|
|
14
|
+
__all__ = ("CorrelationContext", "correlation_context", "get_correlation_adapter")
|
|
15
|
+
|
|
16
|
+
correlation_id_var: "ContextVar[str | None]" = ContextVar("sqlspec_correlation_id", default=None)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CorrelationContext:
|
|
20
|
+
"""Context manager for correlation ID tracking.
|
|
21
|
+
|
|
22
|
+
This class provides a context-aware way to track correlation IDs
|
|
23
|
+
across async and sync operations.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
_correlation_id: ClassVar["ContextVar[str | None]"] = correlation_id_var
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def get(cls) -> str | None:
|
|
30
|
+
"""Get the current correlation ID.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
The current correlation ID or None if not set
|
|
34
|
+
"""
|
|
35
|
+
return cls._correlation_id.get()
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def set(cls, correlation_id: str | None) -> None:
|
|
39
|
+
"""Set the correlation ID.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
correlation_id: The correlation ID to set
|
|
43
|
+
"""
|
|
44
|
+
cls._correlation_id.set(correlation_id)
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def generate(cls) -> str:
|
|
48
|
+
"""Generate a new correlation ID.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
A new UUID-based correlation ID
|
|
52
|
+
"""
|
|
53
|
+
return str(uuid.uuid4())
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
@contextmanager
|
|
57
|
+
def context(cls, correlation_id: str | None = None) -> Generator[str, None, None]:
|
|
58
|
+
"""Context manager for correlation ID scope.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
correlation_id: The correlation ID to use. If None, generates a new one.
|
|
62
|
+
|
|
63
|
+
Yields:
|
|
64
|
+
The correlation ID being used
|
|
65
|
+
"""
|
|
66
|
+
if correlation_id is None:
|
|
67
|
+
correlation_id = cls.generate()
|
|
68
|
+
|
|
69
|
+
previous_id = cls.get()
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
cls.set(correlation_id)
|
|
73
|
+
yield correlation_id
|
|
74
|
+
finally:
|
|
75
|
+
cls.set(previous_id)
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def clear(cls) -> None:
|
|
79
|
+
"""Clear the current correlation ID."""
|
|
80
|
+
cls.set(None)
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def to_dict(cls) -> "dict[str, Any]":
|
|
84
|
+
"""Get correlation context as a dictionary.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
Dictionary with correlation_id key if set
|
|
88
|
+
"""
|
|
89
|
+
correlation_id = cls.get()
|
|
90
|
+
return {"correlation_id": correlation_id} if correlation_id else {}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@contextmanager
|
|
94
|
+
def correlation_context(correlation_id: str | None = None) -> Generator[str, None, None]:
|
|
95
|
+
"""Convenience context manager for correlation ID tracking.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
correlation_id: Optional correlation ID. If None, generates a new one.
|
|
99
|
+
|
|
100
|
+
Yields:
|
|
101
|
+
The active correlation ID
|
|
102
|
+
|
|
103
|
+
Example:
|
|
104
|
+
```python
|
|
105
|
+
with correlation_context() as correlation_id:
|
|
106
|
+
logger.info(
|
|
107
|
+
"Processing request",
|
|
108
|
+
extra={"correlation_id": correlation_id},
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
"""
|
|
112
|
+
with CorrelationContext.context(correlation_id) as cid:
|
|
113
|
+
yield cid
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class _CorrelationAdapter(LoggerAdapter): # pyright: ignore
|
|
117
|
+
"""Logger adapter that adds correlation ID to all logs."""
|
|
118
|
+
|
|
119
|
+
def process(self, msg: str, kwargs: MutableMapping[str, Any]) -> "tuple[str, dict[str, Any]]":
|
|
120
|
+
"""Add correlation ID to the log record."""
|
|
121
|
+
|
|
122
|
+
extra = kwargs.get("extra", {})
|
|
123
|
+
|
|
124
|
+
if correlation_id := CorrelationContext.get():
|
|
125
|
+
extra["correlation_id"] = correlation_id
|
|
126
|
+
|
|
127
|
+
kwargs["extra"] = extra
|
|
128
|
+
return msg, dict(kwargs)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def get_correlation_adapter(logger: Logger | LoggerAdapter) -> LoggerAdapter: # pyright: ignore
|
|
132
|
+
"""Get a logger adapter that automatically includes correlation ID."""
|
|
133
|
+
|
|
134
|
+
return _CorrelationAdapter(logger, {})
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""Deprecation utilities for SQLSpec.
|
|
2
|
+
|
|
3
|
+
Provides decorators and warning functions for marking deprecated functionality.
|
|
4
|
+
Used to communicate API changes and migration paths to users.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import inspect
|
|
8
|
+
from collections.abc import Callable
|
|
9
|
+
from functools import WRAPPER_ASSIGNMENTS, WRAPPER_UPDATES
|
|
10
|
+
from typing import Generic, Literal, cast
|
|
11
|
+
from warnings import warn
|
|
12
|
+
|
|
13
|
+
from typing_extensions import ParamSpec, TypeVar
|
|
14
|
+
|
|
15
|
+
__all__ = ("deprecated", "warn_deprecation")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
T = TypeVar("T")
|
|
19
|
+
P = ParamSpec("P")
|
|
20
|
+
DeprecatedKind = Literal["function", "method", "classmethod", "attribute", "property", "class", "parameter", "import"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def warn_deprecation(
|
|
24
|
+
version: str,
|
|
25
|
+
deprecated_name: str,
|
|
26
|
+
kind: DeprecatedKind,
|
|
27
|
+
*,
|
|
28
|
+
removal_in: str | None = None,
|
|
29
|
+
alternative: str | None = None,
|
|
30
|
+
info: str | None = None,
|
|
31
|
+
pending: bool = False,
|
|
32
|
+
stacklevel: int = 2,
|
|
33
|
+
) -> None:
|
|
34
|
+
"""Warn about a call to a deprecated function.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
version: SQLSpec version where the deprecation will occur
|
|
38
|
+
deprecated_name: Name of the deprecated function
|
|
39
|
+
removal_in: SQLSpec version where the deprecated function will be removed
|
|
40
|
+
alternative: Name of a function that should be used instead
|
|
41
|
+
info: Additional information
|
|
42
|
+
pending: Use :class:`warnings.PendingDeprecationWarning` instead of :class:`warnings.DeprecationWarning`
|
|
43
|
+
kind: Type of the deprecated thing
|
|
44
|
+
stacklevel: Warning stacklevel to report the correct caller site.
|
|
45
|
+
"""
|
|
46
|
+
parts = []
|
|
47
|
+
|
|
48
|
+
if kind == "import":
|
|
49
|
+
access_type = "Import of"
|
|
50
|
+
elif kind in {"function", "method"}:
|
|
51
|
+
access_type = "Call to"
|
|
52
|
+
else:
|
|
53
|
+
access_type = "Use of"
|
|
54
|
+
|
|
55
|
+
if pending:
|
|
56
|
+
parts.append(f"{access_type} {kind} awaiting deprecation '{deprecated_name}'") # pyright: ignore[reportUnknownMemberType]
|
|
57
|
+
else:
|
|
58
|
+
parts.append(f"{access_type} deprecated {kind} '{deprecated_name}'") # pyright: ignore[reportUnknownMemberType]
|
|
59
|
+
|
|
60
|
+
parts.extend( # pyright: ignore[reportUnknownMemberType]
|
|
61
|
+
(f"Deprecated in SQLSpec {version}", f"This {kind} will be removed in {removal_in or 'the next major version'}")
|
|
62
|
+
)
|
|
63
|
+
if alternative:
|
|
64
|
+
parts.append(f"Use {alternative!r} instead") # pyright: ignore[reportUnknownMemberType]
|
|
65
|
+
|
|
66
|
+
if info:
|
|
67
|
+
parts.append(info) # pyright: ignore[reportUnknownMemberType]
|
|
68
|
+
|
|
69
|
+
text = ". ".join(parts) # pyright: ignore[reportUnknownArgumentType]
|
|
70
|
+
warning_class = PendingDeprecationWarning if pending else DeprecationWarning
|
|
71
|
+
|
|
72
|
+
warn(text, warning_class, stacklevel=stacklevel)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def deprecated(
|
|
76
|
+
version: str,
|
|
77
|
+
*,
|
|
78
|
+
removal_in: str | None = None,
|
|
79
|
+
alternative: str | None = None,
|
|
80
|
+
info: str | None = None,
|
|
81
|
+
pending: bool = False,
|
|
82
|
+
kind: Literal["function", "method", "classmethod", "property"] | None = None,
|
|
83
|
+
) -> Callable[[Callable[P, T]], Callable[P, T]]:
|
|
84
|
+
"""Create a decorator wrapping a function, method or property with a deprecation warning.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
version: SQLSpec version where the deprecation will occur
|
|
88
|
+
removal_in: SQLSpec version where the deprecated function will be removed
|
|
89
|
+
alternative: Name of a function that should be used instead
|
|
90
|
+
info: Additional information
|
|
91
|
+
pending: Use :class:`warnings.PendingDeprecationWarning` instead of :class:`warnings.DeprecationWarning`
|
|
92
|
+
kind: Type of the deprecated callable. If ``None``, will use ``inspect`` to figure
|
|
93
|
+
out if it's a function or method
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
A decorator wrapping the function call with a warning
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
return cast(
|
|
100
|
+
"Callable[[Callable[P, T]], Callable[P, T]]",
|
|
101
|
+
_DeprecatedFactory(
|
|
102
|
+
version=version, removal_in=removal_in, alternative=alternative, info=info, pending=pending, kind=kind
|
|
103
|
+
),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class _DeprecatedWrapper(Generic[P, T]):
|
|
108
|
+
__slots__ = ("__dict__", "_alternative", "_func", "_info", "_kind", "_pending", "_removal_in", "_version")
|
|
109
|
+
|
|
110
|
+
def __init__(
|
|
111
|
+
self,
|
|
112
|
+
func: Callable[P, T],
|
|
113
|
+
*,
|
|
114
|
+
version: str,
|
|
115
|
+
removal_in: str | None,
|
|
116
|
+
alternative: str | None,
|
|
117
|
+
info: str | None,
|
|
118
|
+
pending: bool,
|
|
119
|
+
kind: Literal["function", "method", "classmethod", "property"] | None,
|
|
120
|
+
) -> None:
|
|
121
|
+
self._func = func
|
|
122
|
+
self._version = version
|
|
123
|
+
self._removal_in = removal_in
|
|
124
|
+
self._alternative = alternative
|
|
125
|
+
self._info = info
|
|
126
|
+
self._pending = pending
|
|
127
|
+
self._kind = kind
|
|
128
|
+
|
|
129
|
+
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
|
|
130
|
+
kind = cast("DeprecatedKind", self._kind or ("method" if inspect.ismethod(self._func) else "function"))
|
|
131
|
+
warn_deprecation(
|
|
132
|
+
version=self._version,
|
|
133
|
+
deprecated_name=self._func.__name__,
|
|
134
|
+
info=self._info,
|
|
135
|
+
alternative=self._alternative,
|
|
136
|
+
pending=self._pending,
|
|
137
|
+
removal_in=self._removal_in,
|
|
138
|
+
kind=kind,
|
|
139
|
+
)
|
|
140
|
+
return self._func(*args, **kwargs)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class _DeprecatedFactory(Generic[P, T]):
|
|
144
|
+
__slots__ = ("_alternative", "_info", "_kind", "_pending", "_removal_in", "_version")
|
|
145
|
+
|
|
146
|
+
def __init__(
|
|
147
|
+
self,
|
|
148
|
+
*,
|
|
149
|
+
version: str,
|
|
150
|
+
removal_in: str | None,
|
|
151
|
+
alternative: str | None,
|
|
152
|
+
info: str | None,
|
|
153
|
+
pending: bool,
|
|
154
|
+
kind: Literal["function", "method", "classmethod", "property"] | None,
|
|
155
|
+
) -> None:
|
|
156
|
+
self._version = version
|
|
157
|
+
self._removal_in = removal_in
|
|
158
|
+
self._alternative = alternative
|
|
159
|
+
self._info = info
|
|
160
|
+
self._pending = pending
|
|
161
|
+
self._kind: Literal["function", "method", "classmethod", "property"] | None = kind
|
|
162
|
+
|
|
163
|
+
def __call__(self, func: Callable[P, T]) -> Callable[P, T]:
|
|
164
|
+
wrapper = _DeprecatedWrapper(
|
|
165
|
+
func,
|
|
166
|
+
version=self._version,
|
|
167
|
+
removal_in=self._removal_in,
|
|
168
|
+
alternative=self._alternative,
|
|
169
|
+
info=self._info,
|
|
170
|
+
pending=self._pending,
|
|
171
|
+
kind=self._kind,
|
|
172
|
+
)
|
|
173
|
+
return cast("Callable[P, T]", _copy_wrapper_metadata(wrapper, func))
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _copy_wrapper_metadata(wrapper: "_DeprecatedWrapper[P, T]", func: "Callable[P, T]") -> "_DeprecatedWrapper[P, T]":
|
|
177
|
+
assignments: tuple[str, ...] = tuple(WRAPPER_ASSIGNMENTS)
|
|
178
|
+
updates: tuple[str, ...] = tuple(WRAPPER_UPDATES)
|
|
179
|
+
wrapper_dict = wrapper.__dict__
|
|
180
|
+
wrapper_dict.update(getattr(func, "__dict__", {}))
|
|
181
|
+
for attr in assignments:
|
|
182
|
+
if hasattr(func, attr):
|
|
183
|
+
wrapper_dict[attr] = getattr(func, attr)
|
|
184
|
+
wrapper_dict["__wrapped__"] = func
|
|
185
|
+
for attr in updates:
|
|
186
|
+
if attr == "__dict__":
|
|
187
|
+
continue
|
|
188
|
+
if hasattr(func, attr):
|
|
189
|
+
wrapper_dict[attr] = getattr(func, attr)
|
|
190
|
+
return wrapper
|
|
Binary file
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""Fixture loading utilities for SQLSpec.
|
|
2
|
+
|
|
3
|
+
Provides functions for writing, loading and parsing JSON fixture files
|
|
4
|
+
used in testing and development. Supports both sync and async operations.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import gzip
|
|
8
|
+
import zipfile
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import TYPE_CHECKING, Any
|
|
11
|
+
|
|
12
|
+
from sqlspec.storage import storage_registry
|
|
13
|
+
from sqlspec.utils.serializers import from_json as decode_json
|
|
14
|
+
from sqlspec.utils.serializers import schema_dump
|
|
15
|
+
from sqlspec.utils.serializers import to_json as encode_json
|
|
16
|
+
from sqlspec.utils.sync_tools import async_
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from sqlspec.typing import SupportedSchemaModel
|
|
20
|
+
|
|
21
|
+
__all__ = ("open_fixture", "open_fixture_async", "write_fixture", "write_fixture_async")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _read_text_sync(path: "Path") -> str:
|
|
25
|
+
return path.read_text(encoding="utf-8")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _compress_text(content: str) -> bytes:
|
|
29
|
+
return gzip.compress(content.encode("utf-8"))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _read_compressed_file(file_path: Path) -> str:
|
|
33
|
+
"""Read and decompress a file based on its extension.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
file_path: Path to the file to read
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
The decompressed file content as a string
|
|
40
|
+
|
|
41
|
+
Raises:
|
|
42
|
+
ValueError: If the file format is not supported
|
|
43
|
+
"""
|
|
44
|
+
if file_path.suffix == ".gz":
|
|
45
|
+
with gzip.open(file_path, mode="rt", encoding="utf-8") as f:
|
|
46
|
+
return f.read()
|
|
47
|
+
elif file_path.suffix == ".zip":
|
|
48
|
+
with zipfile.ZipFile(file_path, "r") as zf:
|
|
49
|
+
json_name = file_path.stem + ".json"
|
|
50
|
+
if json_name in zf.namelist():
|
|
51
|
+
with zf.open(json_name) as f:
|
|
52
|
+
return f.read().decode("utf-8")
|
|
53
|
+
json_files = [name for name in zf.namelist() if name.endswith(".json")]
|
|
54
|
+
if json_files:
|
|
55
|
+
with zf.open(json_files[0]) as f:
|
|
56
|
+
return f.read().decode("utf-8")
|
|
57
|
+
msg = f"No JSON file found in ZIP archive: {file_path}"
|
|
58
|
+
raise ValueError(msg)
|
|
59
|
+
else:
|
|
60
|
+
msg = f"Unsupported compression format: {file_path.suffix}"
|
|
61
|
+
raise ValueError(msg)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _find_fixture_file(fixtures_path: Any, fixture_name: str) -> Path:
|
|
65
|
+
"""Find a fixture file with various extensions.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
fixtures_path: The path to look for fixtures
|
|
69
|
+
fixture_name: The fixture name to load
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Path to the found fixture file
|
|
73
|
+
|
|
74
|
+
Raises:
|
|
75
|
+
FileNotFoundError: If no fixture file is found
|
|
76
|
+
"""
|
|
77
|
+
base_path = Path(fixtures_path)
|
|
78
|
+
|
|
79
|
+
for extension in [".json", ".json.gz", ".json.zip"]:
|
|
80
|
+
fixture_path = base_path / f"{fixture_name}{extension}"
|
|
81
|
+
if fixture_path.exists():
|
|
82
|
+
return fixture_path
|
|
83
|
+
|
|
84
|
+
msg = f"Could not find the {fixture_name} fixture"
|
|
85
|
+
raise FileNotFoundError(msg)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def open_fixture(fixtures_path: Any, fixture_name: str) -> Any:
|
|
89
|
+
"""Load and parse a JSON fixture file with compression support.
|
|
90
|
+
|
|
91
|
+
Supports reading from:
|
|
92
|
+
- Regular JSON files (.json)
|
|
93
|
+
- Gzipped JSON files (.json.gz)
|
|
94
|
+
- Zipped JSON files (.json.zip)
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
fixtures_path: The path to look for fixtures (pathlib.Path)
|
|
98
|
+
fixture_name: The fixture name to load.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
The parsed JSON data
|
|
103
|
+
"""
|
|
104
|
+
fixture_path = _find_fixture_file(fixtures_path, fixture_name)
|
|
105
|
+
|
|
106
|
+
if fixture_path.suffix in {".gz", ".zip"}:
|
|
107
|
+
f_data = _read_compressed_file(fixture_path)
|
|
108
|
+
else:
|
|
109
|
+
with fixture_path.open(mode="r", encoding="utf-8") as f:
|
|
110
|
+
f_data = f.read()
|
|
111
|
+
|
|
112
|
+
return decode_json(f_data)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
async def open_fixture_async(fixtures_path: Any, fixture_name: str) -> Any:
|
|
116
|
+
"""Load and parse a JSON fixture file asynchronously with compression support.
|
|
117
|
+
|
|
118
|
+
Supports reading from:
|
|
119
|
+
- Regular JSON files (.json)
|
|
120
|
+
- Gzipped JSON files (.json.gz)
|
|
121
|
+
- Zipped JSON files (.json.zip)
|
|
122
|
+
|
|
123
|
+
For compressed files, uses sync reading in a thread pool since gzip and zipfile
|
|
124
|
+
don't have native async equivalents.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
fixtures_path: The path to look for fixtures (pathlib.Path)
|
|
128
|
+
fixture_name: The fixture name to load.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
The parsed JSON data
|
|
133
|
+
"""
|
|
134
|
+
fixture_path = _find_fixture_file(fixtures_path, fixture_name)
|
|
135
|
+
|
|
136
|
+
if fixture_path.suffix in {".gz", ".zip"}:
|
|
137
|
+
read_func = async_(_read_compressed_file)
|
|
138
|
+
f_data = await read_func(fixture_path)
|
|
139
|
+
else:
|
|
140
|
+
async_read = async_(_read_text_sync)
|
|
141
|
+
f_data = await async_read(fixture_path)
|
|
142
|
+
|
|
143
|
+
return decode_json(f_data)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _serialize_data(data: Any) -> str:
|
|
147
|
+
"""Serialize data to JSON string, handling different input types.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
data: Data to serialize. Can be dict, list, or SQLSpec model types
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
JSON string representation of the data
|
|
154
|
+
"""
|
|
155
|
+
if isinstance(data, (list, tuple)):
|
|
156
|
+
serialized_items: list[Any] = []
|
|
157
|
+
|
|
158
|
+
for item in data:
|
|
159
|
+
if isinstance(item, (str, int, float, bool, type(None))):
|
|
160
|
+
serialized_items.append(item)
|
|
161
|
+
else:
|
|
162
|
+
serialized_items.append(schema_dump(item))
|
|
163
|
+
|
|
164
|
+
return encode_json(serialized_items)
|
|
165
|
+
if isinstance(data, (str, int, float, bool, type(None))):
|
|
166
|
+
return encode_json(data)
|
|
167
|
+
|
|
168
|
+
return encode_json(schema_dump(data))
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def write_fixture(
|
|
172
|
+
fixtures_path: str,
|
|
173
|
+
table_name: str,
|
|
174
|
+
data: "list[SupportedSchemaModel] | list[dict[str, Any]] | SupportedSchemaModel",
|
|
175
|
+
storage_backend: str = "local",
|
|
176
|
+
compress: bool = False,
|
|
177
|
+
**storage_kwargs: Any,
|
|
178
|
+
) -> None:
|
|
179
|
+
"""Write fixture data to storage using SQLSpec storage backend.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
fixtures_path: Base path where fixtures should be stored
|
|
183
|
+
table_name: Name of the table/fixture (used as filename)
|
|
184
|
+
data: Data to write - can be list of dicts, models, or single model
|
|
185
|
+
storage_backend: Storage backend to use (default: "local")
|
|
186
|
+
compress: Whether to gzip compress the output
|
|
187
|
+
**storage_kwargs: Additional arguments for the storage backend
|
|
188
|
+
|
|
189
|
+
Raises:
|
|
190
|
+
ValueError: If storage backend is not found
|
|
191
|
+
"""
|
|
192
|
+
if storage_backend == "local":
|
|
193
|
+
uri = "file://"
|
|
194
|
+
storage_kwargs["base_path"] = str(Path(fixtures_path).resolve())
|
|
195
|
+
else:
|
|
196
|
+
uri = storage_backend
|
|
197
|
+
|
|
198
|
+
try:
|
|
199
|
+
storage = storage_registry.get(uri, **storage_kwargs)
|
|
200
|
+
except Exception as exc:
|
|
201
|
+
msg = f"Failed to get storage backend for '{storage_backend}': {exc}"
|
|
202
|
+
raise ValueError(msg) from exc
|
|
203
|
+
|
|
204
|
+
json_content = _serialize_data(data)
|
|
205
|
+
|
|
206
|
+
if compress:
|
|
207
|
+
file_path = f"{table_name}.json.gz"
|
|
208
|
+
content = gzip.compress(json_content.encode("utf-8"))
|
|
209
|
+
storage.write_bytes(file_path, content)
|
|
210
|
+
else:
|
|
211
|
+
file_path = f"{table_name}.json"
|
|
212
|
+
storage.write_text(file_path, json_content)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
async def write_fixture_async(
|
|
216
|
+
fixtures_path: str,
|
|
217
|
+
table_name: str,
|
|
218
|
+
data: "list[SupportedSchemaModel] | list[dict[str, Any]] | SupportedSchemaModel",
|
|
219
|
+
storage_backend: str = "local",
|
|
220
|
+
compress: bool = False,
|
|
221
|
+
**storage_kwargs: Any,
|
|
222
|
+
) -> None:
|
|
223
|
+
"""Write fixture data to storage using SQLSpec storage backend asynchronously.
|
|
224
|
+
|
|
225
|
+
Args:
|
|
226
|
+
fixtures_path: Base path where fixtures should be stored
|
|
227
|
+
table_name: Name of the table/fixture (used as filename)
|
|
228
|
+
data: Data to write - can be list of dicts, models, or single model
|
|
229
|
+
storage_backend: Storage backend to use (default: "local")
|
|
230
|
+
compress: Whether to gzip compress the output
|
|
231
|
+
**storage_kwargs: Additional arguments for the storage backend
|
|
232
|
+
|
|
233
|
+
Raises:
|
|
234
|
+
ValueError: If storage backend is not found
|
|
235
|
+
"""
|
|
236
|
+
if storage_backend == "local":
|
|
237
|
+
uri = "file://"
|
|
238
|
+
storage_kwargs["base_path"] = str(Path(fixtures_path).resolve())
|
|
239
|
+
else:
|
|
240
|
+
uri = storage_backend
|
|
241
|
+
|
|
242
|
+
try:
|
|
243
|
+
storage = storage_registry.get(uri, **storage_kwargs)
|
|
244
|
+
except Exception as exc:
|
|
245
|
+
msg = f"Failed to get storage backend for '{storage_backend}': {exc}"
|
|
246
|
+
raise ValueError(msg) from exc
|
|
247
|
+
|
|
248
|
+
serialize_func = async_(_serialize_data)
|
|
249
|
+
json_content = await serialize_func(data)
|
|
250
|
+
|
|
251
|
+
if compress:
|
|
252
|
+
file_path = f"{table_name}.json.gz"
|
|
253
|
+
compress_func = async_(_compress_text)
|
|
254
|
+
content = await compress_func(json_content)
|
|
255
|
+
await storage.write_bytes_async(file_path, content)
|
|
256
|
+
else:
|
|
257
|
+
file_path = f"{table_name}.json"
|
|
258
|
+
await storage.write_text_async(file_path, json_content)
|