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,280 @@
|
|
|
1
|
+
"""SQLite database configuration with thread-local connections."""
|
|
2
|
+
|
|
3
|
+
import uuid
|
|
4
|
+
from typing import TYPE_CHECKING, Any, ClassVar, TypedDict, cast
|
|
5
|
+
|
|
6
|
+
from typing_extensions import NotRequired
|
|
7
|
+
|
|
8
|
+
from sqlspec.adapters.sqlite._typing import SqliteConnection
|
|
9
|
+
from sqlspec.adapters.sqlite.core import apply_driver_features, build_connection_config, default_statement_config
|
|
10
|
+
from sqlspec.adapters.sqlite.driver import SqliteCursor, SqliteDriver, SqliteExceptionHandler, SqliteSessionContext
|
|
11
|
+
from sqlspec.adapters.sqlite.pool import SqliteConnectionPool
|
|
12
|
+
from sqlspec.adapters.sqlite.type_converter import register_type_handlers
|
|
13
|
+
from sqlspec.config import ExtensionConfigs, SyncDatabaseConfig
|
|
14
|
+
from sqlspec.utils.logging import get_logger
|
|
15
|
+
|
|
16
|
+
logger = get_logger("sqlspec.adapters.sqlite")
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from collections.abc import Callable
|
|
20
|
+
|
|
21
|
+
from sqlspec.core import StatementConfig
|
|
22
|
+
from sqlspec.observability import ObservabilityConfig
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class SqliteConnectionParams(TypedDict):
|
|
26
|
+
"""SQLite connection parameters."""
|
|
27
|
+
|
|
28
|
+
database: NotRequired[str]
|
|
29
|
+
timeout: NotRequired[float]
|
|
30
|
+
detect_types: NotRequired[int]
|
|
31
|
+
isolation_level: "NotRequired[str | None]"
|
|
32
|
+
check_same_thread: NotRequired[bool]
|
|
33
|
+
factory: "NotRequired[type[SqliteConnection] | None]"
|
|
34
|
+
cached_statements: NotRequired[int]
|
|
35
|
+
uri: NotRequired[bool]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class SqliteDriverFeatures(TypedDict):
|
|
39
|
+
"""SQLite driver feature configuration.
|
|
40
|
+
|
|
41
|
+
Controls optional type handling and serialization features for SQLite connections.
|
|
42
|
+
|
|
43
|
+
enable_custom_adapters: Enable custom type adapters for JSON/UUID/datetime conversion.
|
|
44
|
+
Defaults to True for enhanced Python type support.
|
|
45
|
+
Set to False only if you need pure SQLite behavior without type conversions.
|
|
46
|
+
json_serializer: Custom JSON serializer function.
|
|
47
|
+
Defaults to sqlspec.utils.serializers.to_json.
|
|
48
|
+
json_deserializer: Custom JSON deserializer function.
|
|
49
|
+
Defaults to sqlspec.utils.serializers.from_json.
|
|
50
|
+
enable_events: Enable database event channel support.
|
|
51
|
+
Defaults to True when extension_config["events"] is configured.
|
|
52
|
+
Provides pub/sub capabilities via table-backed queue (SQLite has no native pub/sub).
|
|
53
|
+
Requires extension_config["events"] for migration setup.
|
|
54
|
+
events_backend: Event channel backend selection.
|
|
55
|
+
Only option: "table_queue" (durable table-backed queue with retries and exactly-once delivery).
|
|
56
|
+
SQLite does not have native pub/sub, so table_queue is the only backend.
|
|
57
|
+
Defaults to "table_queue".
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
enable_custom_adapters: NotRequired[bool]
|
|
61
|
+
json_serializer: "NotRequired[Callable[[Any], str]]"
|
|
62
|
+
json_deserializer: "NotRequired[Callable[[str], Any]]"
|
|
63
|
+
enable_events: NotRequired[bool]
|
|
64
|
+
events_backend: NotRequired[str]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
__all__ = ("SqliteConfig", "SqliteConnectionParams", "SqliteDriverFeatures")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class SqliteConnectionContext:
|
|
71
|
+
"""Context manager for Sqlite connections."""
|
|
72
|
+
|
|
73
|
+
__slots__ = ("_config", "_ctx")
|
|
74
|
+
|
|
75
|
+
def __init__(self, config: "SqliteConfig") -> None:
|
|
76
|
+
self._config = config
|
|
77
|
+
self._ctx: Any = None
|
|
78
|
+
|
|
79
|
+
def __enter__(self) -> SqliteConnection:
|
|
80
|
+
pool = self._config.provide_pool()
|
|
81
|
+
self._ctx = pool.get_connection()
|
|
82
|
+
return cast("SqliteConnection", self._ctx.__enter__())
|
|
83
|
+
|
|
84
|
+
def __exit__(
|
|
85
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: Any
|
|
86
|
+
) -> bool | None:
|
|
87
|
+
if self._ctx:
|
|
88
|
+
return cast("bool | None", self._ctx.__exit__(exc_type, exc_val, exc_tb))
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class _SqliteSessionConnectionHandler:
|
|
93
|
+
__slots__ = ("_config", "_ctx")
|
|
94
|
+
|
|
95
|
+
def __init__(self, config: "SqliteConfig") -> None:
|
|
96
|
+
self._config = config
|
|
97
|
+
self._ctx: Any = None
|
|
98
|
+
|
|
99
|
+
def acquire_connection(self) -> "SqliteConnection":
|
|
100
|
+
pool = self._config.provide_pool()
|
|
101
|
+
self._ctx = pool.get_connection()
|
|
102
|
+
return cast("SqliteConnection", self._ctx.__enter__())
|
|
103
|
+
|
|
104
|
+
def release_connection(self, _conn: "SqliteConnection") -> None:
|
|
105
|
+
if self._ctx is None:
|
|
106
|
+
return
|
|
107
|
+
self._ctx.__exit__(None, None, None)
|
|
108
|
+
self._ctx = None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class SqliteConfig(SyncDatabaseConfig[SqliteConnection, SqliteConnectionPool, SqliteDriver]):
|
|
112
|
+
"""SQLite configuration with thread-local connections."""
|
|
113
|
+
|
|
114
|
+
driver_type: "ClassVar[type[SqliteDriver]]" = SqliteDriver
|
|
115
|
+
connection_type: "ClassVar[type[SqliteConnection]]" = SqliteConnection
|
|
116
|
+
supports_transactional_ddl: "ClassVar[bool]" = True
|
|
117
|
+
supports_native_arrow_export: "ClassVar[bool]" = True
|
|
118
|
+
supports_native_arrow_import: "ClassVar[bool]" = True
|
|
119
|
+
supports_native_parquet_export: "ClassVar[bool]" = True
|
|
120
|
+
supports_native_parquet_import: "ClassVar[bool]" = True
|
|
121
|
+
|
|
122
|
+
def __init__(
|
|
123
|
+
self,
|
|
124
|
+
*,
|
|
125
|
+
connection_config: "SqliteConnectionParams | dict[str, Any] | None" = None,
|
|
126
|
+
connection_instance: "SqliteConnectionPool | None" = None,
|
|
127
|
+
migration_config: "dict[str, Any] | None" = None,
|
|
128
|
+
statement_config: "StatementConfig | None" = None,
|
|
129
|
+
driver_features: "SqliteDriverFeatures | dict[str, Any] | None" = None,
|
|
130
|
+
bind_key: "str | None" = None,
|
|
131
|
+
extension_config: "ExtensionConfigs | None" = None,
|
|
132
|
+
observability_config: "ObservabilityConfig | None" = None,
|
|
133
|
+
**kwargs: Any,
|
|
134
|
+
) -> None:
|
|
135
|
+
"""Initialize SQLite configuration.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
connection_config: Configuration parameters including connection settings
|
|
139
|
+
connection_instance: Pre-created pool instance
|
|
140
|
+
migration_config: Migration configuration
|
|
141
|
+
statement_config: Default SQL statement configuration
|
|
142
|
+
driver_features: Optional driver feature configuration
|
|
143
|
+
bind_key: Optional bind key for the configuration
|
|
144
|
+
extension_config: Extension-specific configuration (e.g., Litestar plugin settings)
|
|
145
|
+
observability_config: Adapter-level observability overrides for lifecycle hooks and observers
|
|
146
|
+
**kwargs: Additional keyword arguments passed to the base configuration.
|
|
147
|
+
"""
|
|
148
|
+
config_dict: dict[str, Any] = dict(connection_config) if connection_config else {}
|
|
149
|
+
if "database" not in config_dict or config_dict["database"] == ":memory:":
|
|
150
|
+
config_dict["database"] = f"file:memory_{uuid.uuid4().hex}?mode=memory&cache=private"
|
|
151
|
+
config_dict["uri"] = True
|
|
152
|
+
elif "database" in config_dict:
|
|
153
|
+
database_path = str(config_dict["database"])
|
|
154
|
+
if database_path.startswith("file:") and not config_dict.get("uri"):
|
|
155
|
+
logger.debug(
|
|
156
|
+
"Database URI detected (%s) but uri=True not set. "
|
|
157
|
+
"Auto-enabling URI mode to prevent physical file creation.",
|
|
158
|
+
database_path,
|
|
159
|
+
)
|
|
160
|
+
config_dict["uri"] = True
|
|
161
|
+
|
|
162
|
+
statement_config = statement_config or default_statement_config
|
|
163
|
+
statement_config, driver_features = apply_driver_features(statement_config, driver_features)
|
|
164
|
+
|
|
165
|
+
super().__init__(
|
|
166
|
+
bind_key=bind_key,
|
|
167
|
+
connection_instance=connection_instance,
|
|
168
|
+
connection_config=config_dict,
|
|
169
|
+
migration_config=migration_config,
|
|
170
|
+
statement_config=statement_config,
|
|
171
|
+
driver_features=driver_features,
|
|
172
|
+
extension_config=extension_config,
|
|
173
|
+
observability_config=observability_config,
|
|
174
|
+
**kwargs,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
def _create_pool(self) -> SqliteConnectionPool:
|
|
178
|
+
"""Create connection pool from configuration."""
|
|
179
|
+
config_dict = build_connection_config(self.connection_config)
|
|
180
|
+
|
|
181
|
+
pool_kwargs: dict[str, Any] = {}
|
|
182
|
+
recycle_seconds = self.connection_config.get("pool_recycle_seconds")
|
|
183
|
+
if recycle_seconds is not None:
|
|
184
|
+
pool_kwargs["recycle_seconds"] = recycle_seconds
|
|
185
|
+
|
|
186
|
+
health_check_interval = self.connection_config.get("health_check_interval")
|
|
187
|
+
if health_check_interval is not None:
|
|
188
|
+
pool_kwargs["health_check_interval"] = health_check_interval
|
|
189
|
+
|
|
190
|
+
enable_optimizations = self.connection_config.get("enable_optimizations")
|
|
191
|
+
if enable_optimizations is not None:
|
|
192
|
+
pool_kwargs["enable_optimizations"] = enable_optimizations
|
|
193
|
+
|
|
194
|
+
pool = SqliteConnectionPool(connection_parameters=config_dict, **pool_kwargs)
|
|
195
|
+
|
|
196
|
+
if self.driver_features.get("enable_custom_adapters", False):
|
|
197
|
+
self._register_type_adapters()
|
|
198
|
+
|
|
199
|
+
return pool
|
|
200
|
+
|
|
201
|
+
def _register_type_adapters(self) -> None:
|
|
202
|
+
"""Register custom type adapters and converters for SQLite.
|
|
203
|
+
|
|
204
|
+
Called once during pool creation if enable_custom_adapters is True.
|
|
205
|
+
Registers JSON serialization handlers if configured.
|
|
206
|
+
"""
|
|
207
|
+
if self.driver_features.get("enable_custom_adapters", False):
|
|
208
|
+
register_type_handlers(
|
|
209
|
+
json_serializer=self.driver_features.get("json_serializer"),
|
|
210
|
+
json_deserializer=self.driver_features.get("json_deserializer"),
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
def _close_pool(self) -> None:
|
|
214
|
+
"""Close the connection pool."""
|
|
215
|
+
if self.connection_instance:
|
|
216
|
+
self.connection_instance.close()
|
|
217
|
+
|
|
218
|
+
def create_connection(self) -> SqliteConnection:
|
|
219
|
+
"""Get a SQLite connection from the pool.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
SqliteConnection: A connection from the pool
|
|
223
|
+
"""
|
|
224
|
+
pool = self.provide_pool()
|
|
225
|
+
return pool.acquire()
|
|
226
|
+
|
|
227
|
+
def provide_connection(self, *args: "Any", **kwargs: "Any") -> "SqliteConnectionContext":
|
|
228
|
+
"""Provide a SQLite connection context manager.
|
|
229
|
+
|
|
230
|
+
Args:
|
|
231
|
+
*args: Additional arguments.
|
|
232
|
+
**kwargs: Additional keyword arguments.
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
A Sqlite connection context manager.
|
|
236
|
+
"""
|
|
237
|
+
return SqliteConnectionContext(self)
|
|
238
|
+
|
|
239
|
+
def provide_session(
|
|
240
|
+
self, *_args: "Any", statement_config: "StatementConfig | None" = None, **_kwargs: "Any"
|
|
241
|
+
) -> "SqliteSessionContext":
|
|
242
|
+
"""Provide a SQLite driver session.
|
|
243
|
+
|
|
244
|
+
Args:
|
|
245
|
+
*_args: Additional arguments.
|
|
246
|
+
statement_config: Optional statement configuration override.
|
|
247
|
+
**_kwargs: Additional keyword arguments.
|
|
248
|
+
|
|
249
|
+
Returns:
|
|
250
|
+
A Sqlite driver session context manager.
|
|
251
|
+
"""
|
|
252
|
+
handler = _SqliteSessionConnectionHandler(self)
|
|
253
|
+
|
|
254
|
+
return SqliteSessionContext(
|
|
255
|
+
acquire_connection=handler.acquire_connection,
|
|
256
|
+
release_connection=handler.release_connection,
|
|
257
|
+
statement_config=statement_config or self.statement_config or default_statement_config,
|
|
258
|
+
driver_features=self.driver_features,
|
|
259
|
+
prepare_driver=self._prepare_driver,
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
def get_signature_namespace(self) -> "dict[str, Any]":
|
|
263
|
+
"""Get the signature namespace for SQLite types.
|
|
264
|
+
|
|
265
|
+
Returns:
|
|
266
|
+
Dictionary mapping type names to types.
|
|
267
|
+
"""
|
|
268
|
+
namespace = super().get_signature_namespace()
|
|
269
|
+
namespace.update({
|
|
270
|
+
"SqliteConnectionContext": SqliteConnectionContext,
|
|
271
|
+
"SqliteConnection": SqliteConnection,
|
|
272
|
+
"SqliteConnectionParams": SqliteConnectionParams,
|
|
273
|
+
"SqliteConnectionPool": SqliteConnectionPool,
|
|
274
|
+
"SqliteCursor": SqliteCursor,
|
|
275
|
+
"SqliteDriver": SqliteDriver,
|
|
276
|
+
"SqliteDriverFeatures": SqliteDriverFeatures,
|
|
277
|
+
"SqliteExceptionHandler": SqliteExceptionHandler,
|
|
278
|
+
"SqliteSessionContext": SqliteSessionContext,
|
|
279
|
+
})
|
|
280
|
+
return namespace
|
|
Binary file
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"""SQLite adapter compiled helpers."""
|
|
2
|
+
|
|
3
|
+
from datetime import date, datetime
|
|
4
|
+
from decimal import Decimal
|
|
5
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
6
|
+
|
|
7
|
+
from sqlspec.core import DriverParameterProfile, ParameterStyle, StatementConfig, build_statement_config_from_profile
|
|
8
|
+
from sqlspec.exceptions import (
|
|
9
|
+
CheckViolationError,
|
|
10
|
+
DatabaseConnectionError,
|
|
11
|
+
DataError,
|
|
12
|
+
ForeignKeyViolationError,
|
|
13
|
+
IntegrityError,
|
|
14
|
+
NotNullViolationError,
|
|
15
|
+
OperationalError,
|
|
16
|
+
SQLParsingError,
|
|
17
|
+
SQLSpecError,
|
|
18
|
+
UniqueViolationError,
|
|
19
|
+
)
|
|
20
|
+
from sqlspec.utils.serializers import from_json, to_json
|
|
21
|
+
from sqlspec.utils.type_converters import build_decimal_converter, build_time_iso_converter
|
|
22
|
+
from sqlspec.utils.type_guards import has_rowcount, has_sqlite_error
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
26
|
+
|
|
27
|
+
__all__ = (
|
|
28
|
+
"apply_driver_features",
|
|
29
|
+
"build_connection_config",
|
|
30
|
+
"build_insert_statement",
|
|
31
|
+
"build_profile",
|
|
32
|
+
"build_statement_config",
|
|
33
|
+
"collect_rows",
|
|
34
|
+
"create_mapped_exception",
|
|
35
|
+
"default_statement_config",
|
|
36
|
+
"driver_profile",
|
|
37
|
+
"format_identifier",
|
|
38
|
+
"normalize_execute_many_parameters",
|
|
39
|
+
"normalize_execute_parameters",
|
|
40
|
+
"resolve_rowcount",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
SQLITE_CONSTRAINT_UNIQUE_CODE = 2067
|
|
44
|
+
SQLITE_CONSTRAINT_FOREIGNKEY_CODE = 787
|
|
45
|
+
SQLITE_CONSTRAINT_NOTNULL_CODE = 1811
|
|
46
|
+
SQLITE_CONSTRAINT_CHECK_CODE = 531
|
|
47
|
+
SQLITE_CONSTRAINT_CODE = 19
|
|
48
|
+
SQLITE_CANTOPEN_CODE = 14
|
|
49
|
+
SQLITE_IOERR_CODE = 10
|
|
50
|
+
SQLITE_MISMATCH_CODE = 20
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
_TIME_TO_ISO = build_time_iso_converter()
|
|
54
|
+
_DECIMAL_TO_STRING = build_decimal_converter(mode="string")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _bool_to_int(value: bool) -> int:
|
|
58
|
+
return int(value)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _quote_sqlite_identifier(identifier: str) -> str:
|
|
62
|
+
normalized = identifier.replace('"', '""')
|
|
63
|
+
return f'"{normalized}"'
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def format_identifier(identifier: str) -> str:
|
|
67
|
+
cleaned = identifier.strip()
|
|
68
|
+
if not cleaned:
|
|
69
|
+
msg = "Table name must not be empty"
|
|
70
|
+
raise SQLSpecError(msg)
|
|
71
|
+
|
|
72
|
+
if "." not in cleaned:
|
|
73
|
+
return _quote_sqlite_identifier(cleaned)
|
|
74
|
+
|
|
75
|
+
return ".".join(_quote_sqlite_identifier(part) for part in cleaned.split(".") if part)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def build_insert_statement(table: str, columns: "list[str]") -> str:
|
|
79
|
+
column_clause = ", ".join(_quote_sqlite_identifier(column) for column in columns)
|
|
80
|
+
placeholders = ", ".join("?" for _ in columns)
|
|
81
|
+
return f"INSERT INTO {format_identifier(table)} ({column_clause}) VALUES ({placeholders})"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def collect_rows(
|
|
85
|
+
fetched_data: "list[Any]", description: "Sequence[Any] | None"
|
|
86
|
+
) -> "tuple[list[dict[str, Any]], list[str], int]":
|
|
87
|
+
"""Collect SQLite result rows into dictionaries.
|
|
88
|
+
|
|
89
|
+
Optimized helper to convert raw rows and cursor description into list of dicts.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
fetched_data: Raw rows from cursor.fetchall()
|
|
93
|
+
description: Cursor description (tuple of tuples)
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
Tuple of (data, column_names, row_count)
|
|
97
|
+
"""
|
|
98
|
+
if not description:
|
|
99
|
+
return [], [], 0
|
|
100
|
+
|
|
101
|
+
column_names = [col[0] for col in description]
|
|
102
|
+
# compiled list comp and zip is faster in mypyc
|
|
103
|
+
data = [dict(zip(column_names, row, strict=False)) for row in fetched_data]
|
|
104
|
+
return data, column_names, len(data)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def resolve_rowcount(cursor: Any) -> int:
|
|
108
|
+
"""Resolve rowcount from a SQLite cursor.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
cursor: SQLite cursor with optional rowcount metadata.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Positive rowcount value or 0 when unknown.
|
|
115
|
+
"""
|
|
116
|
+
if not has_rowcount(cursor):
|
|
117
|
+
return 0
|
|
118
|
+
rowcount = cursor.rowcount
|
|
119
|
+
if isinstance(rowcount, int) and rowcount > 0:
|
|
120
|
+
return rowcount
|
|
121
|
+
return 0
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def normalize_execute_parameters(parameters: Any) -> Any:
|
|
125
|
+
"""Normalize parameters for SQLite execute calls.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
parameters: Prepared parameters payload.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
Normalized parameters payload.
|
|
132
|
+
"""
|
|
133
|
+
return parameters or ()
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def normalize_execute_many_parameters(parameters: Any) -> Any:
|
|
137
|
+
"""Normalize parameters for SQLite executemany calls.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
parameters: Prepared parameters payload.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
Normalized parameters payload.
|
|
144
|
+
|
|
145
|
+
Raises:
|
|
146
|
+
ValueError: When parameters are missing for executemany.
|
|
147
|
+
"""
|
|
148
|
+
if not parameters:
|
|
149
|
+
msg = "execute_many requires parameters"
|
|
150
|
+
raise ValueError(msg)
|
|
151
|
+
return parameters
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def build_connection_config(connection_config: "Mapping[str, Any]") -> "dict[str, Any]":
|
|
155
|
+
"""Build connection configuration for pool creation.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
connection_config: Raw connection configuration mapping.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
Dictionary with connection parameters.
|
|
162
|
+
"""
|
|
163
|
+
excluded_keys = {
|
|
164
|
+
"enable_optimizations",
|
|
165
|
+
"health_check_interval",
|
|
166
|
+
"pool_min_size",
|
|
167
|
+
"pool_max_size",
|
|
168
|
+
"pool_timeout",
|
|
169
|
+
"pool_recycle_seconds",
|
|
170
|
+
"extra",
|
|
171
|
+
}
|
|
172
|
+
return {key: value for key, value in connection_config.items() if value is not None and key not in excluded_keys}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _create_sqlite_error(
|
|
176
|
+
error: Any, code: "int | None", error_class: type[SQLSpecError], description: str
|
|
177
|
+
) -> SQLSpecError:
|
|
178
|
+
"""Create a SQLSpec exception from a SQLite error.
|
|
179
|
+
|
|
180
|
+
Args:
|
|
181
|
+
error: The original SQLite exception
|
|
182
|
+
code: SQLite extended error code
|
|
183
|
+
error_class: The SQLSpec exception class to instantiate
|
|
184
|
+
description: Human-readable description of the error type
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
A new SQLSpec exception instance with the original as its cause
|
|
188
|
+
"""
|
|
189
|
+
code_str = f"[code {code}]" if code else ""
|
|
190
|
+
msg = f"SQLite {description} {code_str}: {error}" if code_str else f"SQLite {description}: {error}"
|
|
191
|
+
exc = error_class(msg)
|
|
192
|
+
exc.__cause__ = cast("BaseException", error)
|
|
193
|
+
return exc
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def create_mapped_exception(error: BaseException) -> SQLSpecError:
|
|
197
|
+
"""Map SQLite exceptions to SQLSpec exceptions.
|
|
198
|
+
|
|
199
|
+
This is a factory function that returns an exception instance rather than
|
|
200
|
+
raising. This pattern is more robust for use in __exit__ handlers and
|
|
201
|
+
avoids issues with exception control flow in different Python versions.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
error: The SQLite exception to map
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
A SQLSpec exception that wraps the original error
|
|
208
|
+
"""
|
|
209
|
+
if has_sqlite_error(error):
|
|
210
|
+
error_code = error.sqlite_errorcode
|
|
211
|
+
error_name = error.sqlite_errorname
|
|
212
|
+
else:
|
|
213
|
+
error_code = None
|
|
214
|
+
error_name = None
|
|
215
|
+
error_msg = str(error).lower()
|
|
216
|
+
|
|
217
|
+
if "locked" in error_msg:
|
|
218
|
+
return _create_sqlite_error(error, error_code or 0, OperationalError, "operational error")
|
|
219
|
+
|
|
220
|
+
if not error_code:
|
|
221
|
+
if "unique constraint" in error_msg:
|
|
222
|
+
return _create_sqlite_error(error, 0, UniqueViolationError, "unique constraint violation")
|
|
223
|
+
if "foreign key constraint" in error_msg:
|
|
224
|
+
return _create_sqlite_error(error, 0, ForeignKeyViolationError, "foreign key constraint violation")
|
|
225
|
+
if "not null constraint" in error_msg:
|
|
226
|
+
return _create_sqlite_error(error, 0, NotNullViolationError, "not-null constraint violation")
|
|
227
|
+
if "check constraint" in error_msg:
|
|
228
|
+
return _create_sqlite_error(error, 0, CheckViolationError, "check constraint violation")
|
|
229
|
+
if "syntax" in error_msg:
|
|
230
|
+
return _create_sqlite_error(error, None, SQLParsingError, "SQL syntax error")
|
|
231
|
+
return _create_sqlite_error(error, None, SQLSpecError, "database error")
|
|
232
|
+
|
|
233
|
+
if error_code == SQLITE_CONSTRAINT_UNIQUE_CODE or error_name == "SQLITE_CONSTRAINT_UNIQUE":
|
|
234
|
+
return _create_sqlite_error(error, error_code, UniqueViolationError, "unique constraint violation")
|
|
235
|
+
if error_code == SQLITE_CONSTRAINT_FOREIGNKEY_CODE or error_name == "SQLITE_CONSTRAINT_FOREIGNKEY":
|
|
236
|
+
return _create_sqlite_error(error, error_code, ForeignKeyViolationError, "foreign key constraint violation")
|
|
237
|
+
if error_code == SQLITE_CONSTRAINT_NOTNULL_CODE or error_name == "SQLITE_CONSTRAINT_NOTNULL":
|
|
238
|
+
return _create_sqlite_error(error, error_code, NotNullViolationError, "not-null constraint violation")
|
|
239
|
+
if error_code == SQLITE_CONSTRAINT_CHECK_CODE or error_name == "SQLITE_CONSTRAINT_CHECK":
|
|
240
|
+
return _create_sqlite_error(error, error_code, CheckViolationError, "check constraint violation")
|
|
241
|
+
if error_code == SQLITE_CONSTRAINT_CODE or error_name == "SQLITE_CONSTRAINT":
|
|
242
|
+
return _create_sqlite_error(error, error_code, IntegrityError, "integrity constraint violation")
|
|
243
|
+
if error_code == SQLITE_CANTOPEN_CODE or error_name == "SQLITE_CANTOPEN":
|
|
244
|
+
return _create_sqlite_error(error, error_code, DatabaseConnectionError, "connection error")
|
|
245
|
+
if error_code == SQLITE_IOERR_CODE or error_name == "SQLITE_IOERR":
|
|
246
|
+
return _create_sqlite_error(error, error_code, OperationalError, "operational error")
|
|
247
|
+
if error_code == SQLITE_MISMATCH_CODE or error_name == "SQLITE_MISMATCH":
|
|
248
|
+
return _create_sqlite_error(error, error_code, DataError, "data error")
|
|
249
|
+
if error_code == 1 or "syntax" in error_msg:
|
|
250
|
+
return _create_sqlite_error(error, error_code, SQLParsingError, "SQL syntax error")
|
|
251
|
+
return _create_sqlite_error(error, error_code, SQLSpecError, "database error")
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def build_profile() -> "DriverParameterProfile":
|
|
255
|
+
"""Create the SQLite driver parameter profile."""
|
|
256
|
+
|
|
257
|
+
return DriverParameterProfile(
|
|
258
|
+
name="SQLite",
|
|
259
|
+
default_style=ParameterStyle.QMARK,
|
|
260
|
+
supported_styles={ParameterStyle.QMARK, ParameterStyle.NAMED_COLON},
|
|
261
|
+
default_execution_style=ParameterStyle.QMARK,
|
|
262
|
+
supported_execution_styles={ParameterStyle.QMARK, ParameterStyle.NAMED_COLON},
|
|
263
|
+
has_native_list_expansion=False,
|
|
264
|
+
preserve_parameter_format=True,
|
|
265
|
+
needs_static_script_compilation=False,
|
|
266
|
+
allow_mixed_parameter_styles=False,
|
|
267
|
+
preserve_original_params_for_many=False,
|
|
268
|
+
json_serializer_strategy="helper",
|
|
269
|
+
custom_type_coercions={
|
|
270
|
+
bool: _bool_to_int,
|
|
271
|
+
datetime: _TIME_TO_ISO,
|
|
272
|
+
date: _TIME_TO_ISO,
|
|
273
|
+
Decimal: _DECIMAL_TO_STRING,
|
|
274
|
+
},
|
|
275
|
+
default_dialect="sqlite",
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
driver_profile = build_profile()
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def build_statement_config(
|
|
283
|
+
*, json_serializer: "Callable[[Any], str] | None" = None, json_deserializer: "Callable[[str], Any] | None" = None
|
|
284
|
+
) -> "StatementConfig":
|
|
285
|
+
"""Construct the SQLite statement configuration with optional JSON codecs."""
|
|
286
|
+
serializer = json_serializer or to_json
|
|
287
|
+
deserializer = json_deserializer or from_json
|
|
288
|
+
profile = driver_profile
|
|
289
|
+
return build_statement_config_from_profile(
|
|
290
|
+
profile, statement_overrides={"dialect": "sqlite"}, json_serializer=serializer, json_deserializer=deserializer
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
default_statement_config = build_statement_config()
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def apply_driver_features(
|
|
298
|
+
statement_config: "StatementConfig", driver_features: "Mapping[str, Any] | None"
|
|
299
|
+
) -> "tuple[StatementConfig, dict[str, Any]]":
|
|
300
|
+
"""Apply SQLite driver feature defaults to statement config."""
|
|
301
|
+
features: dict[str, Any] = dict(driver_features) if driver_features else {}
|
|
302
|
+
features.setdefault("enable_custom_adapters", True)
|
|
303
|
+
json_serializer = features.setdefault("json_serializer", to_json)
|
|
304
|
+
json_deserializer = features.setdefault("json_deserializer", from_json)
|
|
305
|
+
|
|
306
|
+
if json_serializer is not None:
|
|
307
|
+
parameter_config = statement_config.parameter_config.with_json_serializers(
|
|
308
|
+
json_serializer, deserializer=json_deserializer
|
|
309
|
+
)
|
|
310
|
+
statement_config = statement_config.replace(parameter_config=parameter_config)
|
|
311
|
+
|
|
312
|
+
return statement_config, features
|