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,721 @@
|
|
|
1
|
+
"""Mock driver implementation with dialect transpilation.
|
|
2
|
+
|
|
3
|
+
This module provides sync and async mock drivers that use SQLite `:memory:`
|
|
4
|
+
as the execution backend while accepting SQL written in other dialects
|
|
5
|
+
(Postgres, MySQL, Oracle, etc.). SQL is transpiled to SQLite syntax before
|
|
6
|
+
execution using sqlglot.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import contextlib
|
|
10
|
+
import sqlite3
|
|
11
|
+
from typing import TYPE_CHECKING, Any
|
|
12
|
+
|
|
13
|
+
from sqlspec.adapters.mock._typing import MockAsyncSessionContext, MockSyncSessionContext
|
|
14
|
+
from sqlspec.adapters.mock.core import (
|
|
15
|
+
build_insert_statement,
|
|
16
|
+
collect_rows,
|
|
17
|
+
create_mapped_exception,
|
|
18
|
+
default_statement_config,
|
|
19
|
+
driver_profile,
|
|
20
|
+
format_identifier,
|
|
21
|
+
normalize_execute_many_parameters,
|
|
22
|
+
normalize_execute_parameters,
|
|
23
|
+
resolve_rowcount,
|
|
24
|
+
)
|
|
25
|
+
from sqlspec.adapters.mock.data_dictionary import MockAsyncDataDictionary, MockDataDictionary
|
|
26
|
+
from sqlspec.core import ArrowResult, get_cache_config, register_driver_profile
|
|
27
|
+
from sqlspec.driver import AsyncDriverAdapterBase, SyncDriverAdapterBase, convert_to_dialect
|
|
28
|
+
from sqlspec.exceptions import SQLSpecError
|
|
29
|
+
from sqlspec.utils.sync_tools import async_
|
|
30
|
+
|
|
31
|
+
if TYPE_CHECKING:
|
|
32
|
+
from sqlspec.adapters.mock._typing import MockConnection
|
|
33
|
+
from sqlspec.core import SQL, StatementConfig
|
|
34
|
+
from sqlspec.driver import ExecutionResult
|
|
35
|
+
from sqlspec.storage import StorageBridgeJob, StorageDestination, StorageFormat, StorageTelemetry
|
|
36
|
+
|
|
37
|
+
__all__ = (
|
|
38
|
+
"MockAsyncDriver",
|
|
39
|
+
"MockAsyncSessionContext",
|
|
40
|
+
"MockCursor",
|
|
41
|
+
"MockExceptionHandler",
|
|
42
|
+
"MockSyncDriver",
|
|
43
|
+
"MockSyncSessionContext",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class MockCursor:
|
|
48
|
+
"""Context manager for Mock SQLite cursor management.
|
|
49
|
+
|
|
50
|
+
Provides automatic cursor creation and cleanup for SQLite database operations.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
__slots__ = ("connection", "cursor")
|
|
54
|
+
|
|
55
|
+
def __init__(self, connection: "MockConnection") -> None:
|
|
56
|
+
"""Initialize cursor manager.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
connection: SQLite database connection
|
|
60
|
+
"""
|
|
61
|
+
self.connection = connection
|
|
62
|
+
self.cursor: sqlite3.Cursor | None = None
|
|
63
|
+
|
|
64
|
+
def __enter__(self) -> "sqlite3.Cursor":
|
|
65
|
+
"""Create and return a new cursor.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
Active SQLite cursor object
|
|
69
|
+
"""
|
|
70
|
+
self.cursor = self.connection.cursor()
|
|
71
|
+
return self.cursor
|
|
72
|
+
|
|
73
|
+
def __exit__(self, *_: Any) -> None:
|
|
74
|
+
"""Clean up cursor resources."""
|
|
75
|
+
if self.cursor is not None:
|
|
76
|
+
with contextlib.suppress(Exception):
|
|
77
|
+
self.cursor.close()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class MockAsyncCursor:
|
|
81
|
+
"""Async context manager for Mock SQLite cursor management."""
|
|
82
|
+
|
|
83
|
+
__slots__ = ("connection", "cursor")
|
|
84
|
+
|
|
85
|
+
def __init__(self, connection: "MockConnection") -> None:
|
|
86
|
+
"""Initialize async cursor manager.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
connection: SQLite database connection
|
|
90
|
+
"""
|
|
91
|
+
self.connection = connection
|
|
92
|
+
self.cursor: sqlite3.Cursor | None = None
|
|
93
|
+
|
|
94
|
+
async def __aenter__(self) -> "sqlite3.Cursor":
|
|
95
|
+
"""Create and return a new cursor.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
Active SQLite cursor object
|
|
99
|
+
"""
|
|
100
|
+
self.cursor = self.connection.cursor()
|
|
101
|
+
return self.cursor
|
|
102
|
+
|
|
103
|
+
async def __aexit__(
|
|
104
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: Any
|
|
105
|
+
) -> None:
|
|
106
|
+
"""Clean up cursor resources."""
|
|
107
|
+
if self.cursor is not None:
|
|
108
|
+
with contextlib.suppress(Exception):
|
|
109
|
+
self.cursor.close()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class MockExceptionHandler:
|
|
113
|
+
"""Context manager for handling SQLite database exceptions.
|
|
114
|
+
|
|
115
|
+
Maps SQLite extended result codes to specific SQLSpec exceptions
|
|
116
|
+
for better error handling in application code.
|
|
117
|
+
|
|
118
|
+
Uses deferred exception pattern for mypyc compatibility: exceptions
|
|
119
|
+
are stored in pending_exception rather than raised from __exit__
|
|
120
|
+
to avoid ABI boundary violations with compiled code.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
__slots__ = ("pending_exception",)
|
|
124
|
+
|
|
125
|
+
def __init__(self) -> None:
|
|
126
|
+
self.pending_exception: Exception | None = None
|
|
127
|
+
|
|
128
|
+
def __enter__(self) -> "MockExceptionHandler":
|
|
129
|
+
return self
|
|
130
|
+
|
|
131
|
+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:
|
|
132
|
+
if exc_type is None:
|
|
133
|
+
return False
|
|
134
|
+
if issubclass(exc_type, sqlite3.Error):
|
|
135
|
+
self.pending_exception = create_mapped_exception(exc_val)
|
|
136
|
+
return True
|
|
137
|
+
return False
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class MockAsyncExceptionHandler:
|
|
141
|
+
"""Async context manager for handling SQLite database exceptions.
|
|
142
|
+
|
|
143
|
+
Uses deferred exception pattern for mypyc compatibility.
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
__slots__ = ("pending_exception",)
|
|
147
|
+
|
|
148
|
+
def __init__(self) -> None:
|
|
149
|
+
self.pending_exception: Exception | None = None
|
|
150
|
+
|
|
151
|
+
async def __aenter__(self) -> "MockAsyncExceptionHandler":
|
|
152
|
+
return self
|
|
153
|
+
|
|
154
|
+
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:
|
|
155
|
+
if exc_type is None:
|
|
156
|
+
return False
|
|
157
|
+
if issubclass(exc_type, sqlite3.Error):
|
|
158
|
+
self.pending_exception = create_mapped_exception(exc_val)
|
|
159
|
+
return True
|
|
160
|
+
return False
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class MockSyncDriver(SyncDriverAdapterBase):
|
|
164
|
+
"""Mock sync driver with dialect transpilation.
|
|
165
|
+
|
|
166
|
+
Provides SQL statement execution, transaction management, and result handling
|
|
167
|
+
using SQLite :memory: as the backend. Accepts SQL written in various dialects
|
|
168
|
+
(Postgres, MySQL, Oracle, etc.) and transpiles to SQLite before execution.
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
__slots__ = ("_data_dictionary", "_target_dialect")
|
|
172
|
+
dialect = "sqlite"
|
|
173
|
+
|
|
174
|
+
def __init__(
|
|
175
|
+
self,
|
|
176
|
+
connection: "MockConnection",
|
|
177
|
+
statement_config: "StatementConfig | None" = None,
|
|
178
|
+
driver_features: "dict[str, Any] | None" = None,
|
|
179
|
+
target_dialect: str = "sqlite",
|
|
180
|
+
) -> None:
|
|
181
|
+
"""Initialize Mock sync driver.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
connection: SQLite database connection
|
|
185
|
+
statement_config: Statement configuration settings
|
|
186
|
+
driver_features: Driver-specific feature flags
|
|
187
|
+
target_dialect: Source dialect for SQL transpilation (postgres, mysql, etc.)
|
|
188
|
+
"""
|
|
189
|
+
if statement_config is None:
|
|
190
|
+
statement_config = default_statement_config.replace(
|
|
191
|
+
enable_caching=get_cache_config().compiled_cache_enabled
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
super().__init__(connection=connection, statement_config=statement_config, driver_features=driver_features)
|
|
195
|
+
self._data_dictionary: MockDataDictionary | None = None
|
|
196
|
+
self._target_dialect = target_dialect
|
|
197
|
+
|
|
198
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
199
|
+
# CORE DISPATCH METHODS
|
|
200
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
201
|
+
|
|
202
|
+
def dispatch_execute(self, cursor: "sqlite3.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
203
|
+
"""Execute single SQL statement.
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
cursor: SQLite cursor object
|
|
207
|
+
statement: SQL statement to execute
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
ExecutionResult with statement execution details
|
|
211
|
+
"""
|
|
212
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
213
|
+
cursor.execute(sql, normalize_execute_parameters(prepared_parameters))
|
|
214
|
+
|
|
215
|
+
if statement.returns_rows():
|
|
216
|
+
fetched_data = cursor.fetchall()
|
|
217
|
+
data, column_names, row_count = collect_rows(fetched_data, cursor.description)
|
|
218
|
+
|
|
219
|
+
return self.create_execution_result(
|
|
220
|
+
cursor, selected_data=data, column_names=column_names, data_row_count=row_count, is_select_result=True
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
affected_rows = resolve_rowcount(cursor)
|
|
224
|
+
return self.create_execution_result(cursor, rowcount_override=affected_rows)
|
|
225
|
+
|
|
226
|
+
def dispatch_execute_many(self, cursor: "sqlite3.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
227
|
+
"""Execute SQL with multiple parameter sets.
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
cursor: SQLite cursor object
|
|
231
|
+
statement: SQL statement with multiple parameter sets
|
|
232
|
+
|
|
233
|
+
Returns:
|
|
234
|
+
ExecutionResult with batch execution details
|
|
235
|
+
"""
|
|
236
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
237
|
+
|
|
238
|
+
cursor.executemany(sql, normalize_execute_many_parameters(prepared_parameters))
|
|
239
|
+
|
|
240
|
+
affected_rows = resolve_rowcount(cursor)
|
|
241
|
+
|
|
242
|
+
return self.create_execution_result(cursor, rowcount_override=affected_rows, is_many_result=True)
|
|
243
|
+
|
|
244
|
+
def dispatch_execute_script(self, cursor: "sqlite3.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
245
|
+
"""Execute SQL script with statement splitting and parameter handling.
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
cursor: SQLite cursor object
|
|
249
|
+
statement: SQL statement containing multiple statements
|
|
250
|
+
|
|
251
|
+
Returns:
|
|
252
|
+
ExecutionResult with script execution details
|
|
253
|
+
"""
|
|
254
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
255
|
+
statements = self.split_script_statements(sql, statement.statement_config, strip_trailing_semicolon=True)
|
|
256
|
+
|
|
257
|
+
successful_count = 0
|
|
258
|
+
|
|
259
|
+
for stmt in statements:
|
|
260
|
+
cursor.execute(stmt, normalize_execute_parameters(prepared_parameters))
|
|
261
|
+
successful_count += 1
|
|
262
|
+
|
|
263
|
+
return self.create_execution_result(
|
|
264
|
+
cursor, statement_count=len(statements), successful_statements=successful_count, is_script_result=True
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
268
|
+
# TRANSACTION MANAGEMENT
|
|
269
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
270
|
+
|
|
271
|
+
def begin(self) -> None:
|
|
272
|
+
"""Begin a database transaction.
|
|
273
|
+
|
|
274
|
+
Raises:
|
|
275
|
+
SQLSpecError: If transaction cannot be started
|
|
276
|
+
"""
|
|
277
|
+
try:
|
|
278
|
+
if not self.connection.in_transaction:
|
|
279
|
+
self.connection.execute("BEGIN")
|
|
280
|
+
except sqlite3.Error as e:
|
|
281
|
+
msg = f"Failed to begin transaction: {e}"
|
|
282
|
+
raise SQLSpecError(msg) from e
|
|
283
|
+
|
|
284
|
+
def commit(self) -> None:
|
|
285
|
+
"""Commit the current transaction.
|
|
286
|
+
|
|
287
|
+
Raises:
|
|
288
|
+
SQLSpecError: If transaction cannot be committed
|
|
289
|
+
"""
|
|
290
|
+
try:
|
|
291
|
+
self.connection.commit()
|
|
292
|
+
except sqlite3.Error as e:
|
|
293
|
+
msg = f"Failed to commit transaction: {e}"
|
|
294
|
+
raise SQLSpecError(msg) from e
|
|
295
|
+
|
|
296
|
+
def rollback(self) -> None:
|
|
297
|
+
"""Rollback the current transaction.
|
|
298
|
+
|
|
299
|
+
Raises:
|
|
300
|
+
SQLSpecError: If transaction cannot be rolled back
|
|
301
|
+
"""
|
|
302
|
+
try:
|
|
303
|
+
self.connection.rollback()
|
|
304
|
+
except sqlite3.Error as e:
|
|
305
|
+
msg = f"Failed to rollback transaction: {e}"
|
|
306
|
+
raise SQLSpecError(msg) from e
|
|
307
|
+
|
|
308
|
+
def with_cursor(self, connection: "MockConnection") -> "MockCursor":
|
|
309
|
+
"""Create context manager for SQLite cursor.
|
|
310
|
+
|
|
311
|
+
Args:
|
|
312
|
+
connection: SQLite database connection
|
|
313
|
+
|
|
314
|
+
Returns:
|
|
315
|
+
Cursor context manager for safe cursor operations
|
|
316
|
+
"""
|
|
317
|
+
return MockCursor(connection)
|
|
318
|
+
|
|
319
|
+
def handle_database_exceptions(self) -> "MockExceptionHandler":
|
|
320
|
+
"""Handle database-specific exceptions and wrap them appropriately.
|
|
321
|
+
|
|
322
|
+
Returns:
|
|
323
|
+
Exception handler with deferred exception pattern for mypyc compatibility.
|
|
324
|
+
"""
|
|
325
|
+
return MockExceptionHandler()
|
|
326
|
+
|
|
327
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
328
|
+
# STORAGE API METHODS
|
|
329
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
330
|
+
|
|
331
|
+
def select_to_storage(
|
|
332
|
+
self,
|
|
333
|
+
statement: "SQL | str",
|
|
334
|
+
destination: "StorageDestination",
|
|
335
|
+
/,
|
|
336
|
+
*parameters: Any,
|
|
337
|
+
statement_config: "StatementConfig | None" = None,
|
|
338
|
+
partitioner: "dict[str, object] | None" = None,
|
|
339
|
+
format_hint: "StorageFormat | None" = None,
|
|
340
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
341
|
+
**kwargs: Any,
|
|
342
|
+
) -> "StorageBridgeJob":
|
|
343
|
+
"""Execute a query and write Arrow-compatible output to storage (sync)."""
|
|
344
|
+
self._require_capability("arrow_export_enabled")
|
|
345
|
+
arrow_result = self.select_to_arrow(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
346
|
+
sync_pipeline = self._storage_pipeline()
|
|
347
|
+
telemetry_payload = self._write_result_to_storage_sync(
|
|
348
|
+
arrow_result, destination, format_hint=format_hint, pipeline=sync_pipeline
|
|
349
|
+
)
|
|
350
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
351
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
352
|
+
|
|
353
|
+
def load_from_arrow(
|
|
354
|
+
self,
|
|
355
|
+
table: str,
|
|
356
|
+
source: "ArrowResult | Any",
|
|
357
|
+
*,
|
|
358
|
+
partitioner: "dict[str, object] | None" = None,
|
|
359
|
+
overwrite: bool = False,
|
|
360
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
361
|
+
) -> "StorageBridgeJob":
|
|
362
|
+
"""Load Arrow data into SQLite using batched inserts."""
|
|
363
|
+
self._require_capability("arrow_import_enabled")
|
|
364
|
+
arrow_table = self._coerce_arrow_table(source)
|
|
365
|
+
if overwrite:
|
|
366
|
+
delete_statement = f"DELETE FROM {format_identifier(table)}"
|
|
367
|
+
with self.handle_database_exceptions(), self.with_cursor(self.connection) as cursor:
|
|
368
|
+
cursor.execute(delete_statement)
|
|
369
|
+
|
|
370
|
+
columns, records = self._arrow_table_to_rows(arrow_table)
|
|
371
|
+
if records:
|
|
372
|
+
insert_sql = build_insert_statement(table, columns)
|
|
373
|
+
with self.handle_database_exceptions(), self.with_cursor(self.connection) as cursor:
|
|
374
|
+
cursor.executemany(insert_sql, records)
|
|
375
|
+
|
|
376
|
+
telemetry_payload = self._build_ingest_telemetry(arrow_table)
|
|
377
|
+
telemetry_payload["destination"] = table
|
|
378
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
379
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
380
|
+
|
|
381
|
+
def load_from_storage(
|
|
382
|
+
self,
|
|
383
|
+
table: str,
|
|
384
|
+
source: "StorageDestination",
|
|
385
|
+
*,
|
|
386
|
+
file_format: "StorageFormat",
|
|
387
|
+
partitioner: "dict[str, object] | None" = None,
|
|
388
|
+
overwrite: bool = False,
|
|
389
|
+
) -> "StorageBridgeJob":
|
|
390
|
+
"""Load staged artifacts from storage into SQLite."""
|
|
391
|
+
arrow_table, inbound = self._read_arrow_from_storage_sync(source, file_format=file_format)
|
|
392
|
+
return self.load_from_arrow(table, arrow_table, partitioner=partitioner, overwrite=overwrite, telemetry=inbound)
|
|
393
|
+
|
|
394
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
395
|
+
# UTILITY METHODS
|
|
396
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
397
|
+
|
|
398
|
+
@property
|
|
399
|
+
def data_dictionary(self) -> "MockDataDictionary":
|
|
400
|
+
"""Get the data dictionary for this driver.
|
|
401
|
+
|
|
402
|
+
Returns:
|
|
403
|
+
Data dictionary instance for metadata queries
|
|
404
|
+
"""
|
|
405
|
+
if self._data_dictionary is None:
|
|
406
|
+
self._data_dictionary = MockDataDictionary()
|
|
407
|
+
return self._data_dictionary
|
|
408
|
+
|
|
409
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
410
|
+
# PRIVATE/INTERNAL METHODS
|
|
411
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
412
|
+
|
|
413
|
+
def _transpile_to_sqlite(self, statement: "SQL") -> str:
|
|
414
|
+
"""Convert statement from target dialect to SQLite.
|
|
415
|
+
|
|
416
|
+
Args:
|
|
417
|
+
statement: SQL statement to transpile.
|
|
418
|
+
|
|
419
|
+
Returns:
|
|
420
|
+
Transpiled SQL string compatible with SQLite.
|
|
421
|
+
"""
|
|
422
|
+
if self._target_dialect == "sqlite":
|
|
423
|
+
sql, _ = self._get_compiled_sql(statement, self.statement_config)
|
|
424
|
+
return sql
|
|
425
|
+
return convert_to_dialect(statement, self._target_dialect, "sqlite", pretty=False)
|
|
426
|
+
|
|
427
|
+
def _connection_in_transaction(self) -> bool:
|
|
428
|
+
"""Check if connection is in transaction.
|
|
429
|
+
|
|
430
|
+
Returns:
|
|
431
|
+
True if connection is in an active transaction.
|
|
432
|
+
"""
|
|
433
|
+
return bool(self.connection.in_transaction)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
class MockAsyncDriver(AsyncDriverAdapterBase):
|
|
437
|
+
"""Mock async driver with dialect transpilation.
|
|
438
|
+
|
|
439
|
+
Provides async SQL statement execution using SQLite :memory: as the backend.
|
|
440
|
+
Uses asyncio.to_thread() to wrap sync SQLite operations. Accepts SQL written
|
|
441
|
+
in various dialects (Postgres, MySQL, Oracle, etc.) and transpiles to SQLite.
|
|
442
|
+
"""
|
|
443
|
+
|
|
444
|
+
__slots__ = ("_async_data_dictionary", "_target_dialect")
|
|
445
|
+
dialect = "sqlite"
|
|
446
|
+
|
|
447
|
+
def __init__(
|
|
448
|
+
self,
|
|
449
|
+
connection: "MockConnection",
|
|
450
|
+
statement_config: "StatementConfig | None" = None,
|
|
451
|
+
driver_features: "dict[str, Any] | None" = None,
|
|
452
|
+
target_dialect: str = "sqlite",
|
|
453
|
+
) -> None:
|
|
454
|
+
"""Initialize Mock async driver.
|
|
455
|
+
|
|
456
|
+
Args:
|
|
457
|
+
connection: SQLite database connection
|
|
458
|
+
statement_config: Statement configuration settings
|
|
459
|
+
driver_features: Driver-specific feature flags
|
|
460
|
+
target_dialect: Source dialect for SQL transpilation (postgres, mysql, etc.)
|
|
461
|
+
"""
|
|
462
|
+
if statement_config is None:
|
|
463
|
+
statement_config = default_statement_config.replace(
|
|
464
|
+
enable_caching=get_cache_config().compiled_cache_enabled
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
super().__init__(connection=connection, statement_config=statement_config, driver_features=driver_features)
|
|
468
|
+
self._async_data_dictionary: MockAsyncDataDictionary | None = None
|
|
469
|
+
self._target_dialect = target_dialect
|
|
470
|
+
|
|
471
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
472
|
+
# CORE DISPATCH METHODS
|
|
473
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
474
|
+
|
|
475
|
+
async def dispatch_execute(self, cursor: "sqlite3.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
476
|
+
"""Execute single SQL statement asynchronously.
|
|
477
|
+
|
|
478
|
+
Args:
|
|
479
|
+
cursor: SQLite cursor object
|
|
480
|
+
statement: SQL statement to execute
|
|
481
|
+
|
|
482
|
+
Returns:
|
|
483
|
+
ExecutionResult with statement execution details
|
|
484
|
+
"""
|
|
485
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
486
|
+
|
|
487
|
+
execute_async = async_(cursor.execute)
|
|
488
|
+
await execute_async(sql, normalize_execute_parameters(prepared_parameters))
|
|
489
|
+
|
|
490
|
+
if statement.returns_rows():
|
|
491
|
+
fetchall_async = async_(cursor.fetchall)
|
|
492
|
+
fetched_data = await fetchall_async()
|
|
493
|
+
data, column_names, row_count = collect_rows(fetched_data, cursor.description)
|
|
494
|
+
|
|
495
|
+
return self.create_execution_result(
|
|
496
|
+
cursor, selected_data=data, column_names=column_names, data_row_count=row_count, is_select_result=True
|
|
497
|
+
)
|
|
498
|
+
|
|
499
|
+
affected_rows = resolve_rowcount(cursor)
|
|
500
|
+
return self.create_execution_result(cursor, rowcount_override=affected_rows)
|
|
501
|
+
|
|
502
|
+
async def dispatch_execute_many(self, cursor: "sqlite3.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
503
|
+
"""Execute SQL with multiple parameter sets asynchronously.
|
|
504
|
+
|
|
505
|
+
Args:
|
|
506
|
+
cursor: SQLite cursor object
|
|
507
|
+
statement: SQL statement with multiple parameter sets
|
|
508
|
+
|
|
509
|
+
Returns:
|
|
510
|
+
ExecutionResult with batch execution details
|
|
511
|
+
"""
|
|
512
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
513
|
+
|
|
514
|
+
executemany_async = async_(cursor.executemany)
|
|
515
|
+
await executemany_async(sql, normalize_execute_many_parameters(prepared_parameters))
|
|
516
|
+
|
|
517
|
+
affected_rows = resolve_rowcount(cursor)
|
|
518
|
+
|
|
519
|
+
return self.create_execution_result(cursor, rowcount_override=affected_rows, is_many_result=True)
|
|
520
|
+
|
|
521
|
+
async def dispatch_execute_script(self, cursor: "sqlite3.Cursor", statement: "SQL") -> "ExecutionResult":
|
|
522
|
+
"""Execute SQL script asynchronously.
|
|
523
|
+
|
|
524
|
+
Args:
|
|
525
|
+
cursor: SQLite cursor object
|
|
526
|
+
statement: SQL statement containing multiple statements
|
|
527
|
+
|
|
528
|
+
Returns:
|
|
529
|
+
ExecutionResult with script execution details
|
|
530
|
+
"""
|
|
531
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
532
|
+
statements = self.split_script_statements(sql, statement.statement_config, strip_trailing_semicolon=True)
|
|
533
|
+
|
|
534
|
+
successful_count = 0
|
|
535
|
+
|
|
536
|
+
for stmt in statements:
|
|
537
|
+
execute_async = async_(cursor.execute)
|
|
538
|
+
await execute_async(stmt, normalize_execute_parameters(prepared_parameters))
|
|
539
|
+
successful_count += 1
|
|
540
|
+
|
|
541
|
+
return self.create_execution_result(
|
|
542
|
+
cursor, statement_count=len(statements), successful_statements=successful_count, is_script_result=True
|
|
543
|
+
)
|
|
544
|
+
|
|
545
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
546
|
+
# TRANSACTION MANAGEMENT
|
|
547
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
548
|
+
|
|
549
|
+
async def begin(self) -> None:
|
|
550
|
+
"""Begin a database transaction.
|
|
551
|
+
|
|
552
|
+
Raises:
|
|
553
|
+
SQLSpecError: If transaction cannot be started
|
|
554
|
+
"""
|
|
555
|
+
try:
|
|
556
|
+
if not self.connection.in_transaction:
|
|
557
|
+
execute_async = async_(self.connection.execute)
|
|
558
|
+
await execute_async("BEGIN")
|
|
559
|
+
except sqlite3.Error as e:
|
|
560
|
+
msg = f"Failed to begin transaction: {e}"
|
|
561
|
+
raise SQLSpecError(msg) from e
|
|
562
|
+
|
|
563
|
+
async def commit(self) -> None:
|
|
564
|
+
"""Commit the current transaction.
|
|
565
|
+
|
|
566
|
+
Raises:
|
|
567
|
+
SQLSpecError: If transaction cannot be committed
|
|
568
|
+
"""
|
|
569
|
+
try:
|
|
570
|
+
commit_async = async_(self.connection.commit)
|
|
571
|
+
await commit_async()
|
|
572
|
+
except sqlite3.Error as e:
|
|
573
|
+
msg = f"Failed to commit transaction: {e}"
|
|
574
|
+
raise SQLSpecError(msg) from e
|
|
575
|
+
|
|
576
|
+
async def rollback(self) -> None:
|
|
577
|
+
"""Rollback the current transaction.
|
|
578
|
+
|
|
579
|
+
Raises:
|
|
580
|
+
SQLSpecError: If transaction cannot be rolled back
|
|
581
|
+
"""
|
|
582
|
+
try:
|
|
583
|
+
rollback_async = async_(self.connection.rollback)
|
|
584
|
+
await rollback_async()
|
|
585
|
+
except sqlite3.Error as e:
|
|
586
|
+
msg = f"Failed to rollback transaction: {e}"
|
|
587
|
+
raise SQLSpecError(msg) from e
|
|
588
|
+
|
|
589
|
+
def with_cursor(self, connection: "MockConnection") -> "MockAsyncCursor":
|
|
590
|
+
"""Create async context manager for SQLite cursor.
|
|
591
|
+
|
|
592
|
+
Args:
|
|
593
|
+
connection: SQLite database connection
|
|
594
|
+
|
|
595
|
+
Returns:
|
|
596
|
+
Async cursor context manager
|
|
597
|
+
"""
|
|
598
|
+
return MockAsyncCursor(connection)
|
|
599
|
+
|
|
600
|
+
def handle_database_exceptions(self) -> "MockAsyncExceptionHandler":
|
|
601
|
+
"""Handle database-specific exceptions.
|
|
602
|
+
|
|
603
|
+
Returns:
|
|
604
|
+
Async exception handler with deferred exception pattern.
|
|
605
|
+
"""
|
|
606
|
+
return MockAsyncExceptionHandler()
|
|
607
|
+
|
|
608
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
609
|
+
# STORAGE API METHODS
|
|
610
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
611
|
+
|
|
612
|
+
async def select_to_storage(
|
|
613
|
+
self,
|
|
614
|
+
statement: "SQL | str",
|
|
615
|
+
destination: "StorageDestination",
|
|
616
|
+
/,
|
|
617
|
+
*parameters: Any,
|
|
618
|
+
statement_config: "StatementConfig | None" = None,
|
|
619
|
+
partitioner: "dict[str, object] | None" = None,
|
|
620
|
+
format_hint: "StorageFormat | None" = None,
|
|
621
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
622
|
+
**kwargs: Any,
|
|
623
|
+
) -> "StorageBridgeJob":
|
|
624
|
+
"""Execute a query and stream Arrow results into storage."""
|
|
625
|
+
self._require_capability("arrow_export_enabled")
|
|
626
|
+
arrow_result = await self.select_to_arrow(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
627
|
+
async_pipeline = self._storage_pipeline()
|
|
628
|
+
telemetry_payload = await self._write_result_to_storage_async(
|
|
629
|
+
arrow_result, destination, format_hint=format_hint, pipeline=async_pipeline
|
|
630
|
+
)
|
|
631
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
632
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
633
|
+
|
|
634
|
+
async def load_from_arrow(
|
|
635
|
+
self,
|
|
636
|
+
table: str,
|
|
637
|
+
source: "ArrowResult | Any",
|
|
638
|
+
*,
|
|
639
|
+
partitioner: "dict[str, object] | None" = None,
|
|
640
|
+
overwrite: bool = False,
|
|
641
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
642
|
+
) -> "StorageBridgeJob":
|
|
643
|
+
"""Load Arrow data into SQLite using batched inserts."""
|
|
644
|
+
self._require_capability("arrow_import_enabled")
|
|
645
|
+
arrow_table = self._coerce_arrow_table(source)
|
|
646
|
+
if overwrite:
|
|
647
|
+
delete_statement = f"DELETE FROM {format_identifier(table)}"
|
|
648
|
+
async with self.handle_database_exceptions(), self.with_cursor(self.connection) as cursor:
|
|
649
|
+
execute_async = async_(cursor.execute)
|
|
650
|
+
await execute_async(delete_statement)
|
|
651
|
+
|
|
652
|
+
columns, records = self._arrow_table_to_rows(arrow_table)
|
|
653
|
+
if records:
|
|
654
|
+
insert_sql = build_insert_statement(table, columns)
|
|
655
|
+
async with self.handle_database_exceptions(), self.with_cursor(self.connection) as cursor:
|
|
656
|
+
executemany_async = async_(cursor.executemany)
|
|
657
|
+
await executemany_async(insert_sql, records)
|
|
658
|
+
|
|
659
|
+
telemetry_payload = self._build_ingest_telemetry(arrow_table)
|
|
660
|
+
telemetry_payload["destination"] = table
|
|
661
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
662
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
663
|
+
|
|
664
|
+
async def load_from_storage(
|
|
665
|
+
self,
|
|
666
|
+
table: str,
|
|
667
|
+
source: "StorageDestination",
|
|
668
|
+
*,
|
|
669
|
+
file_format: "StorageFormat",
|
|
670
|
+
partitioner: "dict[str, object] | None" = None,
|
|
671
|
+
overwrite: bool = False,
|
|
672
|
+
) -> "StorageBridgeJob":
|
|
673
|
+
"""Load staged artifacts from storage into SQLite."""
|
|
674
|
+
arrow_table, inbound = await self._read_arrow_from_storage_async(source, file_format=file_format)
|
|
675
|
+
return await self.load_from_arrow(
|
|
676
|
+
table, arrow_table, partitioner=partitioner, overwrite=overwrite, telemetry=inbound
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
680
|
+
# UTILITY METHODS
|
|
681
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
682
|
+
|
|
683
|
+
@property
|
|
684
|
+
def data_dictionary(self) -> "MockAsyncDataDictionary":
|
|
685
|
+
"""Get the async data dictionary for this driver.
|
|
686
|
+
|
|
687
|
+
Returns:
|
|
688
|
+
Async data dictionary instance for metadata queries
|
|
689
|
+
"""
|
|
690
|
+
if self._async_data_dictionary is None:
|
|
691
|
+
self._async_data_dictionary = MockAsyncDataDictionary()
|
|
692
|
+
return self._async_data_dictionary
|
|
693
|
+
|
|
694
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
695
|
+
# PRIVATE/INTERNAL METHODS
|
|
696
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
697
|
+
|
|
698
|
+
def _transpile_to_sqlite(self, statement: "SQL") -> str:
|
|
699
|
+
"""Convert statement from target dialect to SQLite.
|
|
700
|
+
|
|
701
|
+
Args:
|
|
702
|
+
statement: SQL statement to transpile.
|
|
703
|
+
|
|
704
|
+
Returns:
|
|
705
|
+
Transpiled SQL string compatible with SQLite.
|
|
706
|
+
"""
|
|
707
|
+
if self._target_dialect == "sqlite":
|
|
708
|
+
sql, _ = self._get_compiled_sql(statement, self.statement_config)
|
|
709
|
+
return sql
|
|
710
|
+
return convert_to_dialect(statement, self._target_dialect, "sqlite", pretty=False)
|
|
711
|
+
|
|
712
|
+
def _connection_in_transaction(self) -> bool:
|
|
713
|
+
"""Check if connection is in transaction.
|
|
714
|
+
|
|
715
|
+
Returns:
|
|
716
|
+
True if connection is in an active transaction.
|
|
717
|
+
"""
|
|
718
|
+
return bool(self.connection.in_transaction)
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
register_driver_profile("mock", driver_profile)
|