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