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,302 @@
|
|
|
1
|
+
"""Asyncmy database configuration."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any, ClassVar, TypedDict, cast
|
|
4
|
+
|
|
5
|
+
import asyncmy
|
|
6
|
+
from asyncmy.cursors import Cursor, DictCursor # pyright: ignore
|
|
7
|
+
from asyncmy.pool import Pool as AsyncmyPool # pyright: ignore
|
|
8
|
+
from mypy_extensions import mypyc_attr
|
|
9
|
+
from typing_extensions import NotRequired
|
|
10
|
+
|
|
11
|
+
from sqlspec.adapters.asyncmy._typing import AsyncmyConnection
|
|
12
|
+
from sqlspec.adapters.asyncmy.core import apply_driver_features, default_statement_config
|
|
13
|
+
from sqlspec.adapters.asyncmy.driver import AsyncmyCursor, AsyncmyDriver, AsyncmyExceptionHandler, AsyncmySessionContext
|
|
14
|
+
from sqlspec.config import AsyncDatabaseConfig, ExtensionConfigs
|
|
15
|
+
from sqlspec.extensions.events import EventRuntimeHints
|
|
16
|
+
from sqlspec.utils.config_tools import normalize_connection_config, reject_pool_aliases
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from collections.abc import Callable
|
|
20
|
+
|
|
21
|
+
from asyncmy.cursors import Cursor, DictCursor # pyright: ignore
|
|
22
|
+
from asyncmy.pool import Pool # pyright: ignore
|
|
23
|
+
|
|
24
|
+
from sqlspec.core import StatementConfig
|
|
25
|
+
from sqlspec.observability import ObservabilityConfig
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
__all__ = ("AsyncmyConfig", "AsyncmyConnectionParams", "AsyncmyDriverFeatures", "AsyncmyPoolParams")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AsyncmyConnectionParams(TypedDict):
|
|
32
|
+
"""Asyncmy connection parameters."""
|
|
33
|
+
|
|
34
|
+
host: NotRequired[str]
|
|
35
|
+
user: NotRequired[str]
|
|
36
|
+
password: NotRequired[str]
|
|
37
|
+
database: NotRequired[str]
|
|
38
|
+
port: NotRequired[int]
|
|
39
|
+
unix_socket: NotRequired[str]
|
|
40
|
+
charset: NotRequired[str]
|
|
41
|
+
connect_timeout: NotRequired[int]
|
|
42
|
+
read_default_file: NotRequired[str]
|
|
43
|
+
read_default_group: NotRequired[str]
|
|
44
|
+
autocommit: NotRequired[bool]
|
|
45
|
+
local_infile: NotRequired[bool]
|
|
46
|
+
ssl: NotRequired[Any]
|
|
47
|
+
sql_mode: NotRequired[str]
|
|
48
|
+
init_command: NotRequired[str]
|
|
49
|
+
cursor_class: NotRequired[type["Cursor"] | type["DictCursor"]]
|
|
50
|
+
extra: NotRequired["dict[str, Any]"]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class AsyncmyPoolParams(AsyncmyConnectionParams):
|
|
54
|
+
"""Asyncmy pool parameters."""
|
|
55
|
+
|
|
56
|
+
minsize: NotRequired[int]
|
|
57
|
+
maxsize: NotRequired[int]
|
|
58
|
+
echo: NotRequired[bool]
|
|
59
|
+
pool_recycle: NotRequired[int]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class AsyncmyDriverFeatures(TypedDict):
|
|
63
|
+
"""Asyncmy driver feature flags.
|
|
64
|
+
|
|
65
|
+
MySQL/MariaDB handle JSON natively, but custom serializers can be provided
|
|
66
|
+
for specialized use cases (e.g., orjson for performance, msgspec for type safety).
|
|
67
|
+
|
|
68
|
+
json_serializer: Custom JSON serializer function.
|
|
69
|
+
Defaults to sqlspec.utils.serializers.to_json.
|
|
70
|
+
Use for performance (orjson) or custom encoding.
|
|
71
|
+
json_deserializer: Custom JSON deserializer function.
|
|
72
|
+
Defaults to sqlspec.utils.serializers.from_json.
|
|
73
|
+
Use for performance (orjson) or custom decoding.
|
|
74
|
+
enable_events: Enable database event channel support.
|
|
75
|
+
Defaults to True when extension_config["events"] is configured.
|
|
76
|
+
Provides pub/sub capabilities via table-backed queue (MySQL/MariaDB have no native pub/sub).
|
|
77
|
+
Requires extension_config["events"] for migration setup.
|
|
78
|
+
events_backend: Event channel backend selection.
|
|
79
|
+
Only option: "table_queue" (durable table-backed queue with retries and exactly-once delivery).
|
|
80
|
+
MySQL/MariaDB do not have native pub/sub, so table_queue is the only backend.
|
|
81
|
+
Defaults to "table_queue".
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
json_serializer: NotRequired["Callable[[Any], str]"]
|
|
85
|
+
json_deserializer: NotRequired["Callable[[str], Any]"]
|
|
86
|
+
enable_events: NotRequired[bool]
|
|
87
|
+
events_backend: NotRequired[str]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class _AsyncmySessionFactory:
|
|
91
|
+
__slots__ = ("_config", "_ctx")
|
|
92
|
+
|
|
93
|
+
def __init__(self, config: "AsyncmyConfig") -> None:
|
|
94
|
+
self._config = config
|
|
95
|
+
self._ctx: Any | None = None
|
|
96
|
+
|
|
97
|
+
async def acquire_connection(self) -> "AsyncmyConnection":
|
|
98
|
+
pool = self._config.connection_instance
|
|
99
|
+
if pool is None:
|
|
100
|
+
pool = await self._config.create_pool()
|
|
101
|
+
self._config.connection_instance = pool
|
|
102
|
+
ctx = pool.acquire()
|
|
103
|
+
self._ctx = ctx
|
|
104
|
+
return cast("AsyncmyConnection", await ctx.__aenter__())
|
|
105
|
+
|
|
106
|
+
async def release_connection(self, _conn: "AsyncmyConnection") -> None:
|
|
107
|
+
if self._ctx is not None:
|
|
108
|
+
await self._ctx.__aexit__(None, None, None)
|
|
109
|
+
self._ctx = None
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class AsyncmyConnectionContext:
|
|
113
|
+
"""Async context manager for Asyncmy connections."""
|
|
114
|
+
|
|
115
|
+
__slots__ = ("_config", "_ctx")
|
|
116
|
+
|
|
117
|
+
def __init__(self, config: "AsyncmyConfig") -> None:
|
|
118
|
+
self._config = config
|
|
119
|
+
self._ctx: Any = None
|
|
120
|
+
|
|
121
|
+
async def __aenter__(self) -> AsyncmyConnection:
|
|
122
|
+
pool = self._config.connection_instance
|
|
123
|
+
if pool is None:
|
|
124
|
+
pool = await self._config.create_pool()
|
|
125
|
+
self._config.connection_instance = pool
|
|
126
|
+
ctx = pool.acquire()
|
|
127
|
+
self._ctx = ctx
|
|
128
|
+
return cast("AsyncmyConnection", await ctx.__aenter__())
|
|
129
|
+
|
|
130
|
+
async def __aexit__(
|
|
131
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: Any
|
|
132
|
+
) -> bool | None:
|
|
133
|
+
if self._ctx:
|
|
134
|
+
return cast("bool | None", await self._ctx.__aexit__(exc_type, exc_val, exc_tb))
|
|
135
|
+
return None
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@mypyc_attr(native_class=False)
|
|
139
|
+
class AsyncmyConfig(AsyncDatabaseConfig[AsyncmyConnection, "AsyncmyPool", AsyncmyDriver]): # pyright: ignore
|
|
140
|
+
"""Configuration for Asyncmy database connections."""
|
|
141
|
+
|
|
142
|
+
driver_type: ClassVar[type[AsyncmyDriver]] = AsyncmyDriver
|
|
143
|
+
connection_type: "ClassVar[type[Any]]" = cast("type[Any]", AsyncmyConnection)
|
|
144
|
+
supports_transactional_ddl: ClassVar[bool] = False
|
|
145
|
+
supports_native_arrow_export: ClassVar[bool] = True
|
|
146
|
+
supports_native_parquet_export: ClassVar[bool] = True
|
|
147
|
+
supports_native_arrow_import: ClassVar[bool] = True
|
|
148
|
+
supports_native_parquet_import: ClassVar[bool] = True
|
|
149
|
+
|
|
150
|
+
def __init__(
|
|
151
|
+
self,
|
|
152
|
+
*,
|
|
153
|
+
connection_config: "AsyncmyPoolParams | dict[str, Any] | None" = None,
|
|
154
|
+
connection_instance: "AsyncmyPool | None" = None,
|
|
155
|
+
migration_config: "dict[str, Any] | None" = None,
|
|
156
|
+
statement_config: "StatementConfig | None" = None,
|
|
157
|
+
driver_features: "AsyncmyDriverFeatures | dict[str, Any] | None" = None,
|
|
158
|
+
bind_key: "str | None" = None,
|
|
159
|
+
extension_config: "ExtensionConfigs | None" = None,
|
|
160
|
+
observability_config: "ObservabilityConfig | None" = None,
|
|
161
|
+
**kwargs: Any,
|
|
162
|
+
) -> None:
|
|
163
|
+
"""Initialize Asyncmy configuration.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
connection_config: Connection and pool configuration parameters
|
|
167
|
+
connection_instance: Existing pool instance to use
|
|
168
|
+
migration_config: Migration configuration
|
|
169
|
+
statement_config: Statement configuration override
|
|
170
|
+
driver_features: Driver feature configuration (TypedDict or dict)
|
|
171
|
+
bind_key: Optional unique identifier for this configuration
|
|
172
|
+
extension_config: Extension-specific configuration (e.g., Litestar plugin settings)
|
|
173
|
+
observability_config: Adapter-level observability overrides for lifecycle hooks and observers
|
|
174
|
+
**kwargs: Additional keyword arguments
|
|
175
|
+
"""
|
|
176
|
+
reject_pool_aliases(kwargs)
|
|
177
|
+
|
|
178
|
+
connection_config = normalize_connection_config(connection_config)
|
|
179
|
+
|
|
180
|
+
connection_config.setdefault("host", "localhost")
|
|
181
|
+
connection_config.setdefault("port", 3306)
|
|
182
|
+
|
|
183
|
+
statement_config = statement_config or default_statement_config
|
|
184
|
+
statement_config, driver_features = apply_driver_features(statement_config, driver_features)
|
|
185
|
+
|
|
186
|
+
super().__init__(
|
|
187
|
+
connection_config=connection_config,
|
|
188
|
+
connection_instance=connection_instance,
|
|
189
|
+
migration_config=migration_config,
|
|
190
|
+
statement_config=statement_config,
|
|
191
|
+
driver_features=driver_features,
|
|
192
|
+
bind_key=bind_key,
|
|
193
|
+
extension_config=extension_config,
|
|
194
|
+
observability_config=observability_config,
|
|
195
|
+
**kwargs,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
async def _create_pool(self) -> "AsyncmyPool":
|
|
199
|
+
"""Create the actual async connection pool.
|
|
200
|
+
|
|
201
|
+
MySQL/MariaDB handle JSON types natively without requiring connection-level
|
|
202
|
+
type handlers. JSON serialization is handled via type_coercion_map in the
|
|
203
|
+
driver's statement_config (see driver.py).
|
|
204
|
+
|
|
205
|
+
Future driver_features can be added here if needed (e.g., custom connection
|
|
206
|
+
initialization, specialized type handling).
|
|
207
|
+
"""
|
|
208
|
+
return cast("AsyncmyPool", await asyncmy.create_pool(**dict(self.connection_config)))
|
|
209
|
+
|
|
210
|
+
async def _close_pool(self) -> None:
|
|
211
|
+
"""Close the actual async connection pool."""
|
|
212
|
+
if self.connection_instance:
|
|
213
|
+
self.connection_instance.close()
|
|
214
|
+
await self.connection_instance.wait_closed()
|
|
215
|
+
self.connection_instance = None
|
|
216
|
+
|
|
217
|
+
async def close_pool(self) -> None:
|
|
218
|
+
"""Close the connection pool."""
|
|
219
|
+
await self._close_pool()
|
|
220
|
+
|
|
221
|
+
async def create_connection(self) -> AsyncmyConnection:
|
|
222
|
+
"""Create a single async connection (not from pool).
|
|
223
|
+
|
|
224
|
+
Returns:
|
|
225
|
+
An Asyncmy connection instance.
|
|
226
|
+
"""
|
|
227
|
+
pool = self.connection_instance
|
|
228
|
+
if pool is None:
|
|
229
|
+
pool = await self.create_pool()
|
|
230
|
+
self.connection_instance = pool
|
|
231
|
+
return cast("AsyncmyConnection", await pool.acquire())
|
|
232
|
+
|
|
233
|
+
def provide_connection(self, *args: Any, **kwargs: Any) -> "AsyncmyConnectionContext":
|
|
234
|
+
"""Provide an async connection context manager.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
*args: Additional arguments.
|
|
238
|
+
**kwargs: Additional keyword arguments.
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
An Asyncmy connection context manager.
|
|
242
|
+
"""
|
|
243
|
+
return AsyncmyConnectionContext(self)
|
|
244
|
+
|
|
245
|
+
def provide_session(
|
|
246
|
+
self, *_args: Any, statement_config: "StatementConfig | None" = None, **_kwargs: Any
|
|
247
|
+
) -> "AsyncmySessionContext":
|
|
248
|
+
"""Provide an async driver session context manager.
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
*_args: Additional arguments.
|
|
252
|
+
statement_config: Optional statement configuration override.
|
|
253
|
+
**_kwargs: Additional keyword arguments.
|
|
254
|
+
|
|
255
|
+
Returns:
|
|
256
|
+
An Asyncmy driver session context manager.
|
|
257
|
+
"""
|
|
258
|
+
factory = _AsyncmySessionFactory(self)
|
|
259
|
+
return AsyncmySessionContext(
|
|
260
|
+
acquire_connection=factory.acquire_connection,
|
|
261
|
+
release_connection=factory.release_connection,
|
|
262
|
+
statement_config=statement_config or self.statement_config or default_statement_config,
|
|
263
|
+
driver_features=self.driver_features,
|
|
264
|
+
prepare_driver=self._prepare_driver,
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
async def provide_pool(self, *args: Any, **kwargs: Any) -> "Pool":
|
|
268
|
+
"""Provide async pool instance.
|
|
269
|
+
|
|
270
|
+
Returns:
|
|
271
|
+
The async connection pool.
|
|
272
|
+
"""
|
|
273
|
+
if not self.connection_instance:
|
|
274
|
+
self.connection_instance = await self.create_pool()
|
|
275
|
+
return self.connection_instance
|
|
276
|
+
|
|
277
|
+
def get_signature_namespace(self) -> "dict[str, Any]":
|
|
278
|
+
"""Get the signature namespace for Asyncmy types.
|
|
279
|
+
|
|
280
|
+
Returns:
|
|
281
|
+
Dictionary mapping type names to types.
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
namespace = super().get_signature_namespace()
|
|
285
|
+
namespace.update({
|
|
286
|
+
"AsyncmyConnectionContext": AsyncmyConnectionContext,
|
|
287
|
+
"AsyncmyConnection": AsyncmyConnection,
|
|
288
|
+
"AsyncmyConnectionParams": AsyncmyConnectionParams,
|
|
289
|
+
"AsyncmyCursor": AsyncmyCursor,
|
|
290
|
+
"AsyncmyDriver": AsyncmyDriver,
|
|
291
|
+
"AsyncmyDriverFeatures": AsyncmyDriverFeatures,
|
|
292
|
+
"AsyncmyExceptionHandler": AsyncmyExceptionHandler,
|
|
293
|
+
"AsyncmyPool": AsyncmyPool,
|
|
294
|
+
"AsyncmyPoolParams": AsyncmyPoolParams,
|
|
295
|
+
"AsyncmySessionContext": AsyncmySessionContext,
|
|
296
|
+
})
|
|
297
|
+
return namespace
|
|
298
|
+
|
|
299
|
+
def get_event_runtime_hints(self) -> "EventRuntimeHints":
|
|
300
|
+
"""Return queue polling defaults for Asyncmy adapters."""
|
|
301
|
+
|
|
302
|
+
return EventRuntimeHints(poll_interval=0.25, lease_seconds=5, select_for_update=True, skip_locked=True)
|
|
Binary file
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"""AsyncMy adapter compiled helpers."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any
|
|
4
|
+
|
|
5
|
+
from sqlspec.core import DriverParameterProfile, ParameterStyle, StatementConfig, build_statement_config_from_profile
|
|
6
|
+
from sqlspec.exceptions import (
|
|
7
|
+
CheckViolationError,
|
|
8
|
+
DatabaseConnectionError,
|
|
9
|
+
DataError,
|
|
10
|
+
ForeignKeyViolationError,
|
|
11
|
+
IntegrityError,
|
|
12
|
+
NotNullViolationError,
|
|
13
|
+
SQLParsingError,
|
|
14
|
+
SQLSpecError,
|
|
15
|
+
TransactionError,
|
|
16
|
+
UniqueViolationError,
|
|
17
|
+
)
|
|
18
|
+
from sqlspec.utils.serializers import from_json, to_json
|
|
19
|
+
from sqlspec.utils.type_guards import has_cursor_metadata, has_lastrowid, has_rowcount, has_sqlstate, has_type_code
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
23
|
+
|
|
24
|
+
__all__ = (
|
|
25
|
+
"apply_driver_features",
|
|
26
|
+
"build_insert_statement",
|
|
27
|
+
"build_profile",
|
|
28
|
+
"build_statement_config",
|
|
29
|
+
"collect_rows",
|
|
30
|
+
"create_mapped_exception",
|
|
31
|
+
"default_statement_config",
|
|
32
|
+
"detect_json_columns",
|
|
33
|
+
"driver_profile",
|
|
34
|
+
"format_identifier",
|
|
35
|
+
"normalize_execute_many_parameters",
|
|
36
|
+
"normalize_execute_parameters",
|
|
37
|
+
"normalize_lastrowid",
|
|
38
|
+
"resolve_rowcount",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
MYSQL_ER_DUP_ENTRY = 1062
|
|
42
|
+
MYSQL_ER_NO_DEFAULT_FOR_FIELD = 1364
|
|
43
|
+
MYSQL_ER_CHECK_CONSTRAINT_VIOLATED = 3819
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _bool_to_int(value: bool) -> int:
|
|
47
|
+
return int(value)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _quote_mysql_identifier(identifier: str) -> str:
|
|
51
|
+
normalized = identifier.replace("`", "``")
|
|
52
|
+
return f"`{normalized}`"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def format_identifier(identifier: str) -> str:
|
|
56
|
+
cleaned = identifier.strip()
|
|
57
|
+
if not cleaned:
|
|
58
|
+
msg = "Table name must not be empty"
|
|
59
|
+
raise SQLSpecError(msg)
|
|
60
|
+
parts = [part for part in cleaned.split(".") if part]
|
|
61
|
+
formatted = ".".join(_quote_mysql_identifier(part) for part in parts)
|
|
62
|
+
return formatted or _quote_mysql_identifier(cleaned)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def build_insert_statement(table: str, columns: "list[str]") -> str:
|
|
66
|
+
column_clause = ", ".join(_quote_mysql_identifier(column) for column in columns)
|
|
67
|
+
placeholders = ", ".join("%s" for _ in columns)
|
|
68
|
+
return f"INSERT INTO {format_identifier(table)} ({column_clause}) VALUES ({placeholders})"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def normalize_execute_parameters(parameters: Any) -> Any:
|
|
72
|
+
"""Normalize parameters for AsyncMy execute calls.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
parameters: Prepared parameters payload.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Normalized parameters payload.
|
|
79
|
+
"""
|
|
80
|
+
return parameters or None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def normalize_execute_many_parameters(parameters: Any) -> Any:
|
|
84
|
+
"""Normalize parameters for AsyncMy executemany calls.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
parameters: Prepared parameters payload.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Normalized parameters payload.
|
|
91
|
+
|
|
92
|
+
Raises:
|
|
93
|
+
ValueError: When parameters are missing for executemany.
|
|
94
|
+
"""
|
|
95
|
+
if not parameters:
|
|
96
|
+
msg = "execute_many requires parameters"
|
|
97
|
+
raise ValueError(msg)
|
|
98
|
+
return parameters
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def build_profile() -> "DriverParameterProfile":
|
|
102
|
+
"""Create the AsyncMy driver parameter profile."""
|
|
103
|
+
|
|
104
|
+
return DriverParameterProfile(
|
|
105
|
+
name="AsyncMy",
|
|
106
|
+
default_style=ParameterStyle.QMARK,
|
|
107
|
+
supported_styles={ParameterStyle.QMARK, ParameterStyle.POSITIONAL_PYFORMAT},
|
|
108
|
+
default_execution_style=ParameterStyle.POSITIONAL_PYFORMAT,
|
|
109
|
+
supported_execution_styles={ParameterStyle.POSITIONAL_PYFORMAT},
|
|
110
|
+
has_native_list_expansion=False,
|
|
111
|
+
preserve_parameter_format=True,
|
|
112
|
+
needs_static_script_compilation=True,
|
|
113
|
+
allow_mixed_parameter_styles=False,
|
|
114
|
+
preserve_original_params_for_many=False,
|
|
115
|
+
json_serializer_strategy="helper",
|
|
116
|
+
custom_type_coercions={bool: _bool_to_int},
|
|
117
|
+
default_dialect="mysql",
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
driver_profile = build_profile()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def build_statement_config(
|
|
125
|
+
*, json_serializer: "Callable[[Any], str] | None" = None, json_deserializer: "Callable[[str], Any] | None" = None
|
|
126
|
+
) -> "StatementConfig":
|
|
127
|
+
"""Construct the AsyncMy statement configuration with optional JSON codecs."""
|
|
128
|
+
serializer = json_serializer or to_json
|
|
129
|
+
deserializer = json_deserializer or from_json
|
|
130
|
+
profile = driver_profile
|
|
131
|
+
return build_statement_config_from_profile(
|
|
132
|
+
profile, statement_overrides={"dialect": "mysql"}, json_serializer=serializer, json_deserializer=deserializer
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
default_statement_config = build_statement_config()
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def apply_driver_features(
|
|
140
|
+
statement_config: "StatementConfig", driver_features: "Mapping[str, Any] | None"
|
|
141
|
+
) -> "tuple[StatementConfig, dict[str, Any]]":
|
|
142
|
+
"""Apply AsyncMy driver feature defaults to statement config."""
|
|
143
|
+
features: dict[str, Any] = dict(driver_features) if driver_features else {}
|
|
144
|
+
json_serializer = features.setdefault("json_serializer", to_json)
|
|
145
|
+
json_deserializer = features.setdefault("json_deserializer", from_json)
|
|
146
|
+
|
|
147
|
+
if json_serializer is not None:
|
|
148
|
+
parameter_config = statement_config.parameter_config.with_json_serializers(
|
|
149
|
+
json_serializer, deserializer=json_deserializer
|
|
150
|
+
)
|
|
151
|
+
statement_config = statement_config.replace(parameter_config=parameter_config)
|
|
152
|
+
|
|
153
|
+
return statement_config, features
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _create_mysql_error(
|
|
157
|
+
error: Any, sqlstate: "str | None", code: "int | None", error_class: type[SQLSpecError], description: str
|
|
158
|
+
) -> SQLSpecError:
|
|
159
|
+
"""Create a MySQL error instance without raising it."""
|
|
160
|
+
code_str = f"[{sqlstate or code}]" if sqlstate or code else ""
|
|
161
|
+
msg = f"MySQL {description} {code_str}: {error}" if code_str else f"MySQL {description}: {error}"
|
|
162
|
+
exc = error_class(msg)
|
|
163
|
+
exc.__cause__ = error
|
|
164
|
+
return exc
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def create_mapped_exception(error: Any, *, logger: Any | None = None) -> "SQLSpecError | bool":
|
|
168
|
+
"""Map AsyncMy exceptions to SQLSpec errors.
|
|
169
|
+
|
|
170
|
+
This is a factory function that returns an exception instance rather than
|
|
171
|
+
raising. This pattern is more robust for use in __exit__ handlers and
|
|
172
|
+
avoids issues with exception control flow in different Python versions.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
error: The AsyncMy exception to map
|
|
176
|
+
logger: Optional logger for migration warnings
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
True to suppress expected migration errors, or a SQLSpec exception
|
|
180
|
+
"""
|
|
181
|
+
error_code = error.args[0] if len(error.args) >= 1 and isinstance(error.args[0], int) else None
|
|
182
|
+
sqlstate = error.sqlstate if has_sqlstate(error) and error.sqlstate is not None else None
|
|
183
|
+
|
|
184
|
+
if error_code in {1061, 1091}:
|
|
185
|
+
if logger is not None:
|
|
186
|
+
logger.warning("AsyncMy MySQL expected migration error (ignoring): %s", error)
|
|
187
|
+
return True
|
|
188
|
+
|
|
189
|
+
if sqlstate == "23505" or error_code == MYSQL_ER_DUP_ENTRY:
|
|
190
|
+
return _create_mysql_error(error, sqlstate, error_code, UniqueViolationError, "unique constraint violation")
|
|
191
|
+
if sqlstate == "23503" or error_code in {1216, 1217, 1451, 1452}:
|
|
192
|
+
return _create_mysql_error(
|
|
193
|
+
error, sqlstate, error_code, ForeignKeyViolationError, "foreign key constraint violation"
|
|
194
|
+
)
|
|
195
|
+
if sqlstate == "23502" or error_code in {1048, MYSQL_ER_NO_DEFAULT_FOR_FIELD}:
|
|
196
|
+
return _create_mysql_error(error, sqlstate, error_code, NotNullViolationError, "not-null constraint violation")
|
|
197
|
+
if sqlstate == "23514" or error_code == MYSQL_ER_CHECK_CONSTRAINT_VIOLATED:
|
|
198
|
+
return _create_mysql_error(error, sqlstate, error_code, CheckViolationError, "check constraint violation")
|
|
199
|
+
if sqlstate and sqlstate.startswith("23"):
|
|
200
|
+
return _create_mysql_error(error, sqlstate, error_code, IntegrityError, "integrity constraint violation")
|
|
201
|
+
if sqlstate and sqlstate.startswith("42"):
|
|
202
|
+
return _create_mysql_error(error, sqlstate, error_code, SQLParsingError, "SQL syntax error")
|
|
203
|
+
if sqlstate and sqlstate.startswith("08"):
|
|
204
|
+
return _create_mysql_error(error, sqlstate, error_code, DatabaseConnectionError, "connection error")
|
|
205
|
+
if sqlstate and sqlstate.startswith("40"):
|
|
206
|
+
return _create_mysql_error(error, sqlstate, error_code, TransactionError, "transaction error")
|
|
207
|
+
if sqlstate and sqlstate.startswith("22"):
|
|
208
|
+
return _create_mysql_error(error, sqlstate, error_code, DataError, "data error")
|
|
209
|
+
if error_code in {2002, 2003, 2005, 2006, 2013}:
|
|
210
|
+
return _create_mysql_error(error, sqlstate, error_code, DatabaseConnectionError, "connection error")
|
|
211
|
+
if error_code in {1205, 1213}:
|
|
212
|
+
return _create_mysql_error(error, sqlstate, error_code, TransactionError, "transaction error")
|
|
213
|
+
if error_code in range(1064, 1100):
|
|
214
|
+
return _create_mysql_error(error, sqlstate, error_code, SQLParsingError, "SQL syntax error")
|
|
215
|
+
return _create_mysql_error(error, sqlstate, error_code, SQLSpecError, "database error")
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def detect_json_columns(cursor: Any, json_type_codes: "set[int]") -> "list[int]":
|
|
219
|
+
"""Identify JSON column indexes from cursor metadata.
|
|
220
|
+
|
|
221
|
+
Args:
|
|
222
|
+
cursor: Database cursor with description metadata available.
|
|
223
|
+
json_type_codes: Set of type codes identifying JSON columns.
|
|
224
|
+
|
|
225
|
+
Returns:
|
|
226
|
+
List of index positions where JSON values are present.
|
|
227
|
+
"""
|
|
228
|
+
if not has_cursor_metadata(cursor):
|
|
229
|
+
return []
|
|
230
|
+
description = cursor.description
|
|
231
|
+
if not description or not json_type_codes:
|
|
232
|
+
return []
|
|
233
|
+
|
|
234
|
+
json_indexes: list[int] = []
|
|
235
|
+
for index, column in enumerate(description):
|
|
236
|
+
if has_type_code(column):
|
|
237
|
+
type_code = column.type_code
|
|
238
|
+
elif isinstance(column, (tuple, list)) and len(column) > 1:
|
|
239
|
+
type_code = column[1]
|
|
240
|
+
else:
|
|
241
|
+
type_code = None
|
|
242
|
+
if type_code in json_type_codes:
|
|
243
|
+
json_indexes.append(index)
|
|
244
|
+
return json_indexes
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _deserialize_asyncmy_json_rows(
|
|
248
|
+
column_names: "list[str]",
|
|
249
|
+
rows: "list[dict[str, Any]]",
|
|
250
|
+
json_indexes: "list[int]",
|
|
251
|
+
deserializer: "Callable[[Any], Any]",
|
|
252
|
+
*,
|
|
253
|
+
logger: Any | None = None,
|
|
254
|
+
) -> "list[dict[str, Any]]":
|
|
255
|
+
"""Apply JSON deserialization to selected columns.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
column_names: Ordered column names from the cursor description.
|
|
259
|
+
rows: Result rows represented as dictionaries.
|
|
260
|
+
json_indexes: Column indexes to deserialize.
|
|
261
|
+
deserializer: Callable used to decode JSON values.
|
|
262
|
+
logger: Optional logger for debug output.
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
Rows with JSON columns decoded when possible.
|
|
266
|
+
"""
|
|
267
|
+
if not rows or not column_names or not json_indexes:
|
|
268
|
+
return rows
|
|
269
|
+
|
|
270
|
+
target_columns = [column_names[index] for index in json_indexes if index < len(column_names)]
|
|
271
|
+
if not target_columns:
|
|
272
|
+
return rows
|
|
273
|
+
|
|
274
|
+
for row in rows:
|
|
275
|
+
for column in target_columns:
|
|
276
|
+
if column not in row:
|
|
277
|
+
continue
|
|
278
|
+
raw_value = row[column]
|
|
279
|
+
if raw_value is None:
|
|
280
|
+
continue
|
|
281
|
+
if isinstance(raw_value, bytearray):
|
|
282
|
+
raw_value = bytes(raw_value)
|
|
283
|
+
if not isinstance(raw_value, (str, bytes)):
|
|
284
|
+
continue
|
|
285
|
+
try:
|
|
286
|
+
row[column] = deserializer(raw_value)
|
|
287
|
+
except Exception:
|
|
288
|
+
if logger is not None:
|
|
289
|
+
logger.debug("Failed to deserialize JSON column %s", column, exc_info=True)
|
|
290
|
+
return rows
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def collect_rows(
|
|
294
|
+
fetched_data: "Sequence[Any] | None",
|
|
295
|
+
description: "Sequence[Any] | None",
|
|
296
|
+
json_indexes: "list[int]",
|
|
297
|
+
deserializer: "Callable[[Any], Any]",
|
|
298
|
+
*,
|
|
299
|
+
logger: Any | None = None,
|
|
300
|
+
) -> "tuple[list[dict[str, Any]], list[str]]":
|
|
301
|
+
"""Collect AsyncMy rows into dictionaries with JSON decoding.
|
|
302
|
+
|
|
303
|
+
Args:
|
|
304
|
+
fetched_data: Rows returned from cursor.fetchall().
|
|
305
|
+
description: Cursor description metadata.
|
|
306
|
+
json_indexes: Column indexes containing JSON values.
|
|
307
|
+
deserializer: JSON deserializer function.
|
|
308
|
+
logger: Optional logger for debug output.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
Tuple of (rows, column_names).
|
|
312
|
+
"""
|
|
313
|
+
if not description:
|
|
314
|
+
return [], []
|
|
315
|
+
column_names = [desc[0] for desc in description]
|
|
316
|
+
if not fetched_data:
|
|
317
|
+
return [], column_names
|
|
318
|
+
if not isinstance(fetched_data[0], dict):
|
|
319
|
+
rows = [dict(zip(column_names, row, strict=False)) for row in fetched_data]
|
|
320
|
+
else:
|
|
321
|
+
rows = [dict(row) for row in fetched_data]
|
|
322
|
+
rows = _deserialize_asyncmy_json_rows(column_names, rows, json_indexes, deserializer, logger=logger)
|
|
323
|
+
return rows, column_names
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def resolve_rowcount(cursor: Any) -> int:
|
|
327
|
+
"""Resolve rowcount from an AsyncMy cursor.
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
cursor: AsyncMy cursor with optional rowcount metadata.
|
|
331
|
+
|
|
332
|
+
Returns:
|
|
333
|
+
Rowcount value or 0 when unknown.
|
|
334
|
+
"""
|
|
335
|
+
if not has_rowcount(cursor):
|
|
336
|
+
return 0
|
|
337
|
+
rowcount = cursor.rowcount
|
|
338
|
+
if isinstance(rowcount, int) and rowcount >= 0:
|
|
339
|
+
return rowcount
|
|
340
|
+
return 0
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def normalize_lastrowid(cursor: Any) -> int | None:
|
|
344
|
+
"""Normalize lastrowid for AsyncMy when rowcount indicates success.
|
|
345
|
+
|
|
346
|
+
Args:
|
|
347
|
+
cursor: AsyncMy cursor with optional lastrowid metadata.
|
|
348
|
+
|
|
349
|
+
Returns:
|
|
350
|
+
Last inserted id or None when unavailable.
|
|
351
|
+
"""
|
|
352
|
+
if not has_rowcount(cursor):
|
|
353
|
+
return None
|
|
354
|
+
rowcount = cursor.rowcount
|
|
355
|
+
if not isinstance(rowcount, int) or rowcount <= 0:
|
|
356
|
+
return None
|
|
357
|
+
if not has_lastrowid(cursor):
|
|
358
|
+
return None
|
|
359
|
+
last_id = cursor.lastrowid
|
|
360
|
+
return last_id if isinstance(last_id, int) else None
|