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
sqlspec/core/__init__.py
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"""SQLSpec Core Module - SQL Processing System.
|
|
2
|
+
|
|
3
|
+
This module provides the core SQL processing infrastructure for SQLSpec, implementing
|
|
4
|
+
a complete pipeline for SQL statement compilation, parameter processing, caching,
|
|
5
|
+
and result management. All components are optimized for MyPyC compilation to
|
|
6
|
+
reduce overhead.
|
|
7
|
+
|
|
8
|
+
Architecture Overview:
|
|
9
|
+
The core module implements a single-pass processing pipeline where SQL statements
|
|
10
|
+
are parsed once, transformed once, and validated once. The SQL object serves as
|
|
11
|
+
the single source of truth throughout the system.
|
|
12
|
+
|
|
13
|
+
Key Components:
|
|
14
|
+
statement.py: SQL statement representation and configuration management
|
|
15
|
+
- SQL class for statement encapsulation with lazy compilation
|
|
16
|
+
- StatementConfig for processing pipeline configuration
|
|
17
|
+
- ProcessedState for cached compilation results
|
|
18
|
+
- Support for execute_many and script execution modes
|
|
19
|
+
|
|
20
|
+
parameters.py: Type-safe parameter processing and style conversion
|
|
21
|
+
- Automatic parameter style detection and conversion
|
|
22
|
+
- Support for QMARK (?), NAMED (:name), NUMERIC ($1), FORMAT (%s) styles
|
|
23
|
+
- Parameter validation and type coercion
|
|
24
|
+
- Batch parameter handling for execute_many operations
|
|
25
|
+
|
|
26
|
+
compiler.py: SQL compilation with validation and optimization
|
|
27
|
+
- SQLProcessor for statement compilation and validation
|
|
28
|
+
- Operation type detection (SELECT, INSERT, UPDATE, DELETE, etc.)
|
|
29
|
+
- AST-based SQL analysis using SQLGlot
|
|
30
|
+
- Support for multiple SQL dialects
|
|
31
|
+
- Compiled result caching for performance
|
|
32
|
+
|
|
33
|
+
result.py: Comprehensive result handling for all SQL operations
|
|
34
|
+
- SQLResult for standard query results with metadata
|
|
35
|
+
- ArrowResult for Apache Arrow format integration
|
|
36
|
+
- Support for DML operations with RETURNING clauses
|
|
37
|
+
- Script execution result aggregation
|
|
38
|
+
- Iterator protocol support for result rows
|
|
39
|
+
|
|
40
|
+
filters.py: Composable SQL statement filters
|
|
41
|
+
- BeforeAfterFilter for date range filtering
|
|
42
|
+
- InCollectionFilter for IN clause generation
|
|
43
|
+
- LimitOffsetFilter for pagination
|
|
44
|
+
- OrderByFilter for dynamic sorting
|
|
45
|
+
- SearchFilter for text search operations
|
|
46
|
+
- Parameter conflict resolution
|
|
47
|
+
|
|
48
|
+
cache.py: Caching system with LRU eviction
|
|
49
|
+
- LRUCache with configurable TTL and size limits
|
|
50
|
+
- NamespacedCache for statement, expression, optimized, builder, and file caching
|
|
51
|
+
- Thread-safe operations with fine-grained locking
|
|
52
|
+
- Cache statistics and monitoring
|
|
53
|
+
|
|
54
|
+
splitter.py: Dialect-aware SQL script splitting
|
|
55
|
+
- Support for Oracle PL/SQL, T-SQL, PostgreSQL, MySQL
|
|
56
|
+
- Proper handling of block structures (BEGIN/END)
|
|
57
|
+
- Dollar-quoted string support for PostgreSQL
|
|
58
|
+
- Batch separator recognition (GO for T-SQL)
|
|
59
|
+
- Comment and string literal preservation
|
|
60
|
+
|
|
61
|
+
hashing.py: Efficient cache key generation
|
|
62
|
+
- SQL statement hashing with parameter consideration
|
|
63
|
+
- Expression tree hashing for AST caching
|
|
64
|
+
- Parameter set hashing for batch operations
|
|
65
|
+
- Optimized hash computation with caching
|
|
66
|
+
|
|
67
|
+
Performance Optimizations:
|
|
68
|
+
- MyPyC compilation support with proper annotations
|
|
69
|
+
- __slots__ usage for memory efficiency
|
|
70
|
+
- Final annotations for constant folding
|
|
71
|
+
- Lazy evaluation and compilation
|
|
72
|
+
- Comprehensive result caching
|
|
73
|
+
- Minimal object allocation in hot paths
|
|
74
|
+
|
|
75
|
+
Thread Safety:
|
|
76
|
+
All caching components are thread-safe with RLock protection.
|
|
77
|
+
The processing pipeline is stateless and safe for concurrent use.
|
|
78
|
+
|
|
79
|
+
Example Usage:
|
|
80
|
+
>>> from sqlspec.core import SQL, StatementConfig
|
|
81
|
+
>>> config = StatementConfig(dialect="postgresql")
|
|
82
|
+
>>> stmt = SQL(
|
|
83
|
+
... "SELECT * FROM users WHERE id = ?",
|
|
84
|
+
... 1,
|
|
85
|
+
... statement_config=config,
|
|
86
|
+
... )
|
|
87
|
+
>>> compiled_sql, params = stmt.compile()
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
from sqlspec.core import filters
|
|
91
|
+
from sqlspec.core._correlation import CorrelationExtractor
|
|
92
|
+
from sqlspec.core.cache import (
|
|
93
|
+
CacheConfig,
|
|
94
|
+
CachedStatement,
|
|
95
|
+
CacheKey,
|
|
96
|
+
CacheStats,
|
|
97
|
+
FiltersView,
|
|
98
|
+
LRUCache,
|
|
99
|
+
NamespacedCache,
|
|
100
|
+
canonicalize_filters,
|
|
101
|
+
clear_all_caches,
|
|
102
|
+
create_cache_key,
|
|
103
|
+
get_cache,
|
|
104
|
+
get_cache_config,
|
|
105
|
+
get_cache_statistics,
|
|
106
|
+
get_cache_stats,
|
|
107
|
+
get_default_cache,
|
|
108
|
+
get_pipeline_metrics,
|
|
109
|
+
log_cache_stats,
|
|
110
|
+
reset_cache_stats,
|
|
111
|
+
reset_pipeline_registry,
|
|
112
|
+
update_cache_config,
|
|
113
|
+
)
|
|
114
|
+
from sqlspec.core.compiler import (
|
|
115
|
+
CompiledSQL,
|
|
116
|
+
OperationProfile,
|
|
117
|
+
OperationType,
|
|
118
|
+
SQLProcessor,
|
|
119
|
+
is_copy_from_operation,
|
|
120
|
+
is_copy_operation,
|
|
121
|
+
is_copy_to_operation,
|
|
122
|
+
)
|
|
123
|
+
from sqlspec.core.explain import ExplainFormat, ExplainOptions
|
|
124
|
+
from sqlspec.core.filters import (
|
|
125
|
+
AnyCollectionFilter,
|
|
126
|
+
BeforeAfterFilter,
|
|
127
|
+
FilterTypes,
|
|
128
|
+
FilterTypeT,
|
|
129
|
+
InCollectionFilter,
|
|
130
|
+
LimitOffsetFilter,
|
|
131
|
+
NotInCollectionFilter,
|
|
132
|
+
NotNullFilter,
|
|
133
|
+
NullFilter,
|
|
134
|
+
OrderByFilter,
|
|
135
|
+
SearchFilter,
|
|
136
|
+
StatementFilter,
|
|
137
|
+
apply_filter,
|
|
138
|
+
)
|
|
139
|
+
from sqlspec.core.hashing import (
|
|
140
|
+
hash_expression,
|
|
141
|
+
hash_expression_node,
|
|
142
|
+
hash_filters,
|
|
143
|
+
hash_optimized_expression,
|
|
144
|
+
hash_parameters,
|
|
145
|
+
hash_sql_statement,
|
|
146
|
+
)
|
|
147
|
+
from sqlspec.core.metrics import StackExecutionMetrics
|
|
148
|
+
from sqlspec.core.parameters import (
|
|
149
|
+
DRIVER_PARAMETER_PROFILES,
|
|
150
|
+
EXECUTE_MANY_MIN_ROWS,
|
|
151
|
+
PARAMETER_REGEX,
|
|
152
|
+
DriverParameterProfile,
|
|
153
|
+
ParameterConverter,
|
|
154
|
+
ParameterInfo,
|
|
155
|
+
ParameterProcessingResult,
|
|
156
|
+
ParameterProcessor,
|
|
157
|
+
ParameterProfile,
|
|
158
|
+
ParameterStyle,
|
|
159
|
+
ParameterStyleConfig,
|
|
160
|
+
ParameterValidator,
|
|
161
|
+
TypedParameter,
|
|
162
|
+
build_literal_inlining_transform,
|
|
163
|
+
build_null_pruning_transform,
|
|
164
|
+
build_statement_config_from_profile,
|
|
165
|
+
collect_null_parameter_ordinals,
|
|
166
|
+
get_driver_profile,
|
|
167
|
+
is_iterable_parameters,
|
|
168
|
+
looks_like_execute_many,
|
|
169
|
+
normalize_parameter_key,
|
|
170
|
+
register_driver_profile,
|
|
171
|
+
replace_null_parameters_with_literals,
|
|
172
|
+
replace_placeholders_with_literals,
|
|
173
|
+
validate_parameter_alignment,
|
|
174
|
+
wrap_with_type,
|
|
175
|
+
)
|
|
176
|
+
from sqlspec.core.query_modifiers import (
|
|
177
|
+
ConditionFactory,
|
|
178
|
+
apply_limit,
|
|
179
|
+
apply_offset,
|
|
180
|
+
apply_or_where,
|
|
181
|
+
apply_select_only,
|
|
182
|
+
apply_where,
|
|
183
|
+
create_between_condition,
|
|
184
|
+
create_condition,
|
|
185
|
+
create_exists_condition,
|
|
186
|
+
create_in_condition,
|
|
187
|
+
create_not_exists_condition,
|
|
188
|
+
create_not_in_condition,
|
|
189
|
+
expr_eq,
|
|
190
|
+
expr_gt,
|
|
191
|
+
expr_gte,
|
|
192
|
+
expr_ilike,
|
|
193
|
+
expr_is_not_null,
|
|
194
|
+
expr_is_null,
|
|
195
|
+
expr_like,
|
|
196
|
+
expr_lt,
|
|
197
|
+
expr_lte,
|
|
198
|
+
expr_neq,
|
|
199
|
+
expr_not_like,
|
|
200
|
+
extract_column_name,
|
|
201
|
+
parse_column_for_condition,
|
|
202
|
+
safe_modify_with_cte,
|
|
203
|
+
)
|
|
204
|
+
from sqlspec.core.result import (
|
|
205
|
+
ArrowResult,
|
|
206
|
+
SQLResult,
|
|
207
|
+
StackResult,
|
|
208
|
+
StatementResult,
|
|
209
|
+
build_arrow_result_from_table,
|
|
210
|
+
create_arrow_result,
|
|
211
|
+
create_sql_result,
|
|
212
|
+
)
|
|
213
|
+
from sqlspec.core.splitter import split_sql_script
|
|
214
|
+
from sqlspec.core.stack import StackOperation, StatementStack
|
|
215
|
+
from sqlspec.core.statement import (
|
|
216
|
+
SQL,
|
|
217
|
+
ProcessedState,
|
|
218
|
+
Statement,
|
|
219
|
+
StatementConfig,
|
|
220
|
+
get_default_config,
|
|
221
|
+
get_default_parameter_config,
|
|
222
|
+
)
|
|
223
|
+
from sqlspec.core.type_converter import (
|
|
224
|
+
DEFAULT_CACHE_SIZE,
|
|
225
|
+
DEFAULT_SPECIAL_CHARS,
|
|
226
|
+
BaseInputConverter,
|
|
227
|
+
BaseTypeConverter,
|
|
228
|
+
CachedOutputConverter,
|
|
229
|
+
convert_decimal,
|
|
230
|
+
convert_iso_date,
|
|
231
|
+
convert_iso_datetime,
|
|
232
|
+
convert_iso_time,
|
|
233
|
+
convert_json,
|
|
234
|
+
convert_uuid,
|
|
235
|
+
format_datetime_rfc3339,
|
|
236
|
+
parse_datetime_rfc3339,
|
|
237
|
+
)
|
|
238
|
+
from sqlspec.exceptions import StackExecutionError
|
|
239
|
+
|
|
240
|
+
__all__ = (
|
|
241
|
+
"DEFAULT_CACHE_SIZE",
|
|
242
|
+
"DEFAULT_SPECIAL_CHARS",
|
|
243
|
+
"DRIVER_PARAMETER_PROFILES",
|
|
244
|
+
"EXECUTE_MANY_MIN_ROWS",
|
|
245
|
+
"PARAMETER_REGEX",
|
|
246
|
+
"SQL",
|
|
247
|
+
"AnyCollectionFilter",
|
|
248
|
+
"ArrowResult",
|
|
249
|
+
"BaseInputConverter",
|
|
250
|
+
"BaseTypeConverter",
|
|
251
|
+
"BeforeAfterFilter",
|
|
252
|
+
"CacheConfig",
|
|
253
|
+
"CacheKey",
|
|
254
|
+
"CacheStats",
|
|
255
|
+
"CachedOutputConverter",
|
|
256
|
+
"CachedStatement",
|
|
257
|
+
"CompiledSQL",
|
|
258
|
+
"ConditionFactory",
|
|
259
|
+
"CorrelationExtractor",
|
|
260
|
+
"DriverParameterProfile",
|
|
261
|
+
"ExplainFormat",
|
|
262
|
+
"ExplainOptions",
|
|
263
|
+
"FilterTypeT",
|
|
264
|
+
"FilterTypes",
|
|
265
|
+
"FiltersView",
|
|
266
|
+
"InCollectionFilter",
|
|
267
|
+
"LRUCache",
|
|
268
|
+
"LimitOffsetFilter",
|
|
269
|
+
"NamespacedCache",
|
|
270
|
+
"NotInCollectionFilter",
|
|
271
|
+
"NotNullFilter",
|
|
272
|
+
"NullFilter",
|
|
273
|
+
"OperationProfile",
|
|
274
|
+
"OperationType",
|
|
275
|
+
"OrderByFilter",
|
|
276
|
+
"ParameterConverter",
|
|
277
|
+
"ParameterInfo",
|
|
278
|
+
"ParameterProcessingResult",
|
|
279
|
+
"ParameterProcessor",
|
|
280
|
+
"ParameterProfile",
|
|
281
|
+
"ParameterStyle",
|
|
282
|
+
"ParameterStyleConfig",
|
|
283
|
+
"ParameterValidator",
|
|
284
|
+
"ProcessedState",
|
|
285
|
+
"SQLProcessor",
|
|
286
|
+
"SQLResult",
|
|
287
|
+
"SearchFilter",
|
|
288
|
+
"StackExecutionError",
|
|
289
|
+
"StackExecutionMetrics",
|
|
290
|
+
"StackOperation",
|
|
291
|
+
"StackResult",
|
|
292
|
+
"Statement",
|
|
293
|
+
"StatementConfig",
|
|
294
|
+
"StatementFilter",
|
|
295
|
+
"StatementResult",
|
|
296
|
+
"StatementStack",
|
|
297
|
+
"TypedParameter",
|
|
298
|
+
"apply_filter",
|
|
299
|
+
"apply_limit",
|
|
300
|
+
"apply_offset",
|
|
301
|
+
"apply_or_where",
|
|
302
|
+
"apply_select_only",
|
|
303
|
+
"apply_where",
|
|
304
|
+
"build_arrow_result_from_table",
|
|
305
|
+
"build_literal_inlining_transform",
|
|
306
|
+
"build_null_pruning_transform",
|
|
307
|
+
"build_statement_config_from_profile",
|
|
308
|
+
"canonicalize_filters",
|
|
309
|
+
"clear_all_caches",
|
|
310
|
+
"collect_null_parameter_ordinals",
|
|
311
|
+
"convert_decimal",
|
|
312
|
+
"convert_iso_date",
|
|
313
|
+
"convert_iso_datetime",
|
|
314
|
+
"convert_iso_time",
|
|
315
|
+
"convert_json",
|
|
316
|
+
"convert_uuid",
|
|
317
|
+
"create_arrow_result",
|
|
318
|
+
"create_between_condition",
|
|
319
|
+
"create_cache_key",
|
|
320
|
+
"create_condition",
|
|
321
|
+
"create_exists_condition",
|
|
322
|
+
"create_in_condition",
|
|
323
|
+
"create_not_exists_condition",
|
|
324
|
+
"create_not_in_condition",
|
|
325
|
+
"create_sql_result",
|
|
326
|
+
"expr_eq",
|
|
327
|
+
"expr_gt",
|
|
328
|
+
"expr_gte",
|
|
329
|
+
"expr_ilike",
|
|
330
|
+
"expr_is_not_null",
|
|
331
|
+
"expr_is_null",
|
|
332
|
+
"expr_like",
|
|
333
|
+
"expr_lt",
|
|
334
|
+
"expr_lte",
|
|
335
|
+
"expr_neq",
|
|
336
|
+
"expr_not_like",
|
|
337
|
+
"extract_column_name",
|
|
338
|
+
"filters",
|
|
339
|
+
"format_datetime_rfc3339",
|
|
340
|
+
"get_cache",
|
|
341
|
+
"get_cache_config",
|
|
342
|
+
"get_cache_statistics",
|
|
343
|
+
"get_cache_stats",
|
|
344
|
+
"get_default_cache",
|
|
345
|
+
"get_default_config",
|
|
346
|
+
"get_default_parameter_config",
|
|
347
|
+
"get_driver_profile",
|
|
348
|
+
"get_pipeline_metrics",
|
|
349
|
+
"hash_expression",
|
|
350
|
+
"hash_expression_node",
|
|
351
|
+
"hash_filters",
|
|
352
|
+
"hash_optimized_expression",
|
|
353
|
+
"hash_parameters",
|
|
354
|
+
"hash_sql_statement",
|
|
355
|
+
"is_copy_from_operation",
|
|
356
|
+
"is_copy_operation",
|
|
357
|
+
"is_copy_to_operation",
|
|
358
|
+
"is_iterable_parameters",
|
|
359
|
+
"log_cache_stats",
|
|
360
|
+
"looks_like_execute_many",
|
|
361
|
+
"normalize_parameter_key",
|
|
362
|
+
"parse_column_for_condition",
|
|
363
|
+
"parse_datetime_rfc3339",
|
|
364
|
+
"register_driver_profile",
|
|
365
|
+
"replace_null_parameters_with_literals",
|
|
366
|
+
"replace_placeholders_with_literals",
|
|
367
|
+
"reset_cache_stats",
|
|
368
|
+
"reset_pipeline_registry",
|
|
369
|
+
"safe_modify_with_cte",
|
|
370
|
+
"split_sql_script",
|
|
371
|
+
"update_cache_config",
|
|
372
|
+
"validate_parameter_alignment",
|
|
373
|
+
"wrap_with_type",
|
|
374
|
+
)
|
|
Binary file
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""Correlation ID extraction from HTTP request headers.
|
|
2
|
+
|
|
3
|
+
This module provides a reusable correlation ID extractor that can be used
|
|
4
|
+
across different web frameworks (Starlette, FastAPI, Flask) to extract
|
|
5
|
+
correlation IDs from request headers with consistent behavior.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from collections.abc import Callable
|
|
9
|
+
from typing import ClassVar
|
|
10
|
+
|
|
11
|
+
from sqlspec.utils.correlation import CorrelationContext
|
|
12
|
+
|
|
13
|
+
__all__ = ("CorrelationExtractor",)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CorrelationExtractor:
|
|
17
|
+
"""Extracts correlation IDs from HTTP request headers.
|
|
18
|
+
|
|
19
|
+
This class provides configurable header extraction with:
|
|
20
|
+
- Configurable primary header (highest priority)
|
|
21
|
+
- Additional custom headers (middle priority)
|
|
22
|
+
- Standard trace context headers as fallbacks
|
|
23
|
+
- Automatic UUID generation when no header found
|
|
24
|
+
- Input sanitization (max length, whitespace trimming)
|
|
25
|
+
|
|
26
|
+
The extractor follows a priority order: primary header first, then
|
|
27
|
+
configured headers, then trace context fallbacks (if enabled).
|
|
28
|
+
|
|
29
|
+
Example:
|
|
30
|
+
```python
|
|
31
|
+
extractor = CorrelationExtractor(
|
|
32
|
+
primary_header="x-request-id",
|
|
33
|
+
additional_headers=("x-correlation-id",),
|
|
34
|
+
auto_trace_headers=True,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# In Starlette/FastAPI:
|
|
38
|
+
correlation_id = extractor.extract(
|
|
39
|
+
lambda h: request.headers.get(h)
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# In Flask:
|
|
43
|
+
correlation_id = extractor.extract(
|
|
44
|
+
lambda h: request.headers.get(h)
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
__slots__ = ("_headers", "_max_length")
|
|
50
|
+
|
|
51
|
+
DEFAULT_HEADERS: ClassVar[tuple[str, ...]] = (
|
|
52
|
+
"x-request-id",
|
|
53
|
+
"x-correlation-id",
|
|
54
|
+
"traceparent",
|
|
55
|
+
"x-cloud-trace-context",
|
|
56
|
+
"x-amzn-trace-id",
|
|
57
|
+
"x-b3-traceid",
|
|
58
|
+
"x-client-trace-id",
|
|
59
|
+
"grpc-trace-bin",
|
|
60
|
+
)
|
|
61
|
+
"""Default trace context headers to check as fallbacks.
|
|
62
|
+
|
|
63
|
+
These headers cover:
|
|
64
|
+
- x-request-id: Common request ID header
|
|
65
|
+
- x-correlation-id: Common correlation ID header
|
|
66
|
+
- traceparent: W3C Trace Context standard
|
|
67
|
+
- x-cloud-trace-context: Google Cloud trace header
|
|
68
|
+
- x-amzn-trace-id: AWS X-Ray trace header
|
|
69
|
+
- x-b3-traceid: Zipkin B3 propagation
|
|
70
|
+
- x-client-trace-id: Envoy proxy trace header
|
|
71
|
+
- grpc-trace-bin: gRPC binary trace header
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
DEFAULT_MAX_LENGTH: ClassVar[int] = 128
|
|
75
|
+
"""Maximum length for correlation IDs to prevent log injection."""
|
|
76
|
+
|
|
77
|
+
def __init__(
|
|
78
|
+
self,
|
|
79
|
+
*,
|
|
80
|
+
primary_header: str = "x-request-id",
|
|
81
|
+
additional_headers: tuple[str, ...] | None = None,
|
|
82
|
+
auto_trace_headers: bool = True,
|
|
83
|
+
max_length: int | None = None,
|
|
84
|
+
) -> None:
|
|
85
|
+
"""Initialize the correlation extractor.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
primary_header: The primary header to check first. Defaults to "x-request-id".
|
|
89
|
+
additional_headers: Additional headers to check after the primary header.
|
|
90
|
+
auto_trace_headers: If True, include standard trace context headers as fallbacks.
|
|
91
|
+
max_length: Maximum length for correlation IDs. Defaults to 128.
|
|
92
|
+
"""
|
|
93
|
+
headers: list[str] = [primary_header.lower()]
|
|
94
|
+
|
|
95
|
+
if additional_headers:
|
|
96
|
+
headers.extend(h.lower() for h in additional_headers)
|
|
97
|
+
|
|
98
|
+
if auto_trace_headers:
|
|
99
|
+
headers.extend(self.DEFAULT_HEADERS)
|
|
100
|
+
|
|
101
|
+
# Remove duplicates while preserving order
|
|
102
|
+
self._headers = tuple(dict.fromkeys(headers))
|
|
103
|
+
self._max_length = max_length if max_length is not None else self.DEFAULT_MAX_LENGTH
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def headers(self) -> tuple[str, ...]:
|
|
107
|
+
"""Get the ordered list of headers to check."""
|
|
108
|
+
return self._headers
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def max_length(self) -> int:
|
|
112
|
+
"""Get the maximum correlation ID length."""
|
|
113
|
+
return self._max_length
|
|
114
|
+
|
|
115
|
+
def extract(self, get_header: Callable[[str], str | None]) -> str:
|
|
116
|
+
"""Extract correlation ID from headers or generate a new one.
|
|
117
|
+
|
|
118
|
+
Iterates through configured headers in priority order and returns
|
|
119
|
+
the first non-empty value found. If no header contains a value,
|
|
120
|
+
generates a new UUID.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
get_header: A callable that takes a header name (lowercase) and
|
|
124
|
+
returns the header value or None.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
The extracted or generated correlation ID.
|
|
128
|
+
|
|
129
|
+
Example:
|
|
130
|
+
```python
|
|
131
|
+
# With Starlette Request
|
|
132
|
+
correlation_id = extractor.extract(
|
|
133
|
+
lambda h: request.headers.get(h)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
# With Flask request
|
|
137
|
+
from flask import request
|
|
138
|
+
|
|
139
|
+
correlation_id = extractor.extract(
|
|
140
|
+
lambda h: request.headers.get(h)
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
"""
|
|
144
|
+
for header in self._headers:
|
|
145
|
+
value = get_header(header)
|
|
146
|
+
if value:
|
|
147
|
+
return self._sanitize(value)
|
|
148
|
+
|
|
149
|
+
return CorrelationContext.generate()
|
|
150
|
+
|
|
151
|
+
def _sanitize(self, value: str) -> str:
|
|
152
|
+
"""Sanitize a correlation ID value.
|
|
153
|
+
|
|
154
|
+
Strips whitespace and truncates to max length to prevent
|
|
155
|
+
log injection attacks and excessively long IDs.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
value: The raw correlation ID value.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
The sanitized correlation ID, or a generated UUID if
|
|
162
|
+
the sanitized value is empty.
|
|
163
|
+
"""
|
|
164
|
+
sanitized = value.strip()[: self._max_length]
|
|
165
|
+
return sanitized if sanitized else CorrelationContext.generate()
|
|
166
|
+
|
|
167
|
+
def __repr__(self) -> str:
|
|
168
|
+
return f"CorrelationExtractor(headers={self._headers!r}, max_length={self._max_length!r})"
|
|
169
|
+
|
|
170
|
+
def __eq__(self, other: object) -> bool:
|
|
171
|
+
if not isinstance(other, CorrelationExtractor):
|
|
172
|
+
return NotImplemented
|
|
173
|
+
return self._headers == other._headers and self._max_length == other._max_length
|
|
174
|
+
|
|
175
|
+
def __hash__(self) -> int:
|
|
176
|
+
return hash((self._headers, self._max_length))
|
|
Binary file
|