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,195 @@
|
|
|
1
|
+
"""PyMySQL database configuration."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any, ClassVar, TypedDict, cast
|
|
4
|
+
|
|
5
|
+
from typing_extensions import NotRequired
|
|
6
|
+
|
|
7
|
+
from sqlspec.adapters.pymysql._typing import PyMysqlConnection, PyMysqlSessionContext
|
|
8
|
+
from sqlspec.adapters.pymysql.core import apply_driver_features, default_statement_config
|
|
9
|
+
from sqlspec.adapters.pymysql.driver import PyMysqlCursor, PyMysqlDriver, PyMysqlExceptionHandler
|
|
10
|
+
from sqlspec.adapters.pymysql.pool import PyMysqlConnectionPool
|
|
11
|
+
from sqlspec.config import ExtensionConfigs, SyncDatabaseConfig
|
|
12
|
+
from sqlspec.extensions.events import EventRuntimeHints
|
|
13
|
+
from sqlspec.utils.config_tools import normalize_connection_config
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from collections.abc import Callable
|
|
17
|
+
|
|
18
|
+
from sqlspec.core import StatementConfig
|
|
19
|
+
from sqlspec.observability import ObservabilityConfig
|
|
20
|
+
|
|
21
|
+
__all__ = ("PyMysqlConfig", "PyMysqlConnectionParams", "PyMysqlDriverFeatures", "PyMysqlPoolParams")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class PyMysqlConnectionParams(TypedDict):
|
|
25
|
+
"""PyMySQL connection parameters."""
|
|
26
|
+
|
|
27
|
+
host: NotRequired[str]
|
|
28
|
+
user: NotRequired[str]
|
|
29
|
+
password: NotRequired[str]
|
|
30
|
+
database: NotRequired[str]
|
|
31
|
+
port: NotRequired[int]
|
|
32
|
+
unix_socket: NotRequired[str]
|
|
33
|
+
charset: NotRequired[str]
|
|
34
|
+
connect_timeout: NotRequired[int]
|
|
35
|
+
read_timeout: NotRequired[int]
|
|
36
|
+
write_timeout: NotRequired[int]
|
|
37
|
+
autocommit: NotRequired[bool]
|
|
38
|
+
ssl: NotRequired["dict[str, Any]"]
|
|
39
|
+
client_flag: NotRequired[int]
|
|
40
|
+
cursorclass: NotRequired[type]
|
|
41
|
+
init_command: NotRequired[str]
|
|
42
|
+
sql_mode: NotRequired[str]
|
|
43
|
+
extra: NotRequired["dict[str, Any]"]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class PyMysqlPoolParams(PyMysqlConnectionParams):
|
|
47
|
+
"""PyMySQL pool parameters."""
|
|
48
|
+
|
|
49
|
+
pool_recycle_seconds: NotRequired[int]
|
|
50
|
+
health_check_interval: NotRequired[float]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class PyMysqlDriverFeatures(TypedDict):
|
|
54
|
+
"""PyMySQL driver feature flags."""
|
|
55
|
+
|
|
56
|
+
json_serializer: NotRequired["Callable[[Any], str]"]
|
|
57
|
+
json_deserializer: NotRequired["Callable[[str], Any]"]
|
|
58
|
+
enable_events: NotRequired[bool]
|
|
59
|
+
events_backend: NotRequired[str]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class PyMysqlConnectionContext:
|
|
63
|
+
"""Context manager for PyMySQL connections."""
|
|
64
|
+
|
|
65
|
+
__slots__ = ("_config", "_ctx")
|
|
66
|
+
|
|
67
|
+
def __init__(self, config: "PyMysqlConfig") -> None:
|
|
68
|
+
self._config = config
|
|
69
|
+
self._ctx: Any = None
|
|
70
|
+
|
|
71
|
+
def __enter__(self) -> PyMysqlConnection:
|
|
72
|
+
pool = self._config.provide_pool()
|
|
73
|
+
self._ctx = pool.get_connection()
|
|
74
|
+
return cast("PyMysqlConnection", self._ctx.__enter__())
|
|
75
|
+
|
|
76
|
+
def __exit__(
|
|
77
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: Any
|
|
78
|
+
) -> bool | None:
|
|
79
|
+
if self._ctx:
|
|
80
|
+
return cast("bool | None", self._ctx.__exit__(exc_type, exc_val, exc_tb))
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class _PyMysqlSessionConnectionHandler:
|
|
85
|
+
__slots__ = ("_config", "_ctx")
|
|
86
|
+
|
|
87
|
+
def __init__(self, config: "PyMysqlConfig") -> None:
|
|
88
|
+
self._config = config
|
|
89
|
+
self._ctx: Any = None
|
|
90
|
+
|
|
91
|
+
def acquire_connection(self) -> "PyMysqlConnection":
|
|
92
|
+
pool = self._config.provide_pool()
|
|
93
|
+
self._ctx = pool.get_connection()
|
|
94
|
+
return cast("PyMysqlConnection", self._ctx.__enter__())
|
|
95
|
+
|
|
96
|
+
def release_connection(self, _conn: "PyMysqlConnection") -> None:
|
|
97
|
+
if self._ctx is None:
|
|
98
|
+
return
|
|
99
|
+
self._ctx.__exit__(None, None, None)
|
|
100
|
+
self._ctx = None
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class PyMysqlConfig(SyncDatabaseConfig[PyMysqlConnection, PyMysqlConnectionPool, PyMysqlDriver]):
|
|
104
|
+
"""Configuration for PyMySQL synchronous connections."""
|
|
105
|
+
|
|
106
|
+
driver_type: "ClassVar[type[PyMysqlDriver]]" = PyMysqlDriver
|
|
107
|
+
connection_type: "ClassVar[type[PyMysqlConnection]]" = cast("type[PyMysqlConnection]", PyMysqlConnection)
|
|
108
|
+
supports_transactional_ddl: "ClassVar[bool]" = False
|
|
109
|
+
supports_native_arrow_export: "ClassVar[bool]" = True
|
|
110
|
+
supports_native_arrow_import: "ClassVar[bool]" = True
|
|
111
|
+
supports_native_parquet_export: "ClassVar[bool]" = True
|
|
112
|
+
supports_native_parquet_import: "ClassVar[bool]" = True
|
|
113
|
+
|
|
114
|
+
def __init__(
|
|
115
|
+
self,
|
|
116
|
+
*,
|
|
117
|
+
connection_config: "PyMysqlPoolParams | dict[str, Any] | None" = None,
|
|
118
|
+
connection_instance: "PyMysqlConnectionPool | None" = None,
|
|
119
|
+
migration_config: "dict[str, Any] | None" = None,
|
|
120
|
+
statement_config: "StatementConfig | None" = None,
|
|
121
|
+
driver_features: "PyMysqlDriverFeatures | dict[str, Any] | None" = None,
|
|
122
|
+
bind_key: "str | None" = None,
|
|
123
|
+
extension_config: "ExtensionConfigs | None" = None,
|
|
124
|
+
observability_config: "ObservabilityConfig | None" = None,
|
|
125
|
+
**kwargs: Any,
|
|
126
|
+
) -> None:
|
|
127
|
+
connection_config = normalize_connection_config(connection_config)
|
|
128
|
+
connection_config.setdefault("host", "localhost")
|
|
129
|
+
connection_config.setdefault("port", 3306)
|
|
130
|
+
|
|
131
|
+
statement_config = statement_config or default_statement_config
|
|
132
|
+
statement_config, driver_features = apply_driver_features(statement_config, driver_features)
|
|
133
|
+
|
|
134
|
+
super().__init__(
|
|
135
|
+
connection_config=connection_config,
|
|
136
|
+
connection_instance=connection_instance,
|
|
137
|
+
migration_config=migration_config,
|
|
138
|
+
statement_config=statement_config,
|
|
139
|
+
driver_features=driver_features,
|
|
140
|
+
bind_key=bind_key,
|
|
141
|
+
extension_config=extension_config,
|
|
142
|
+
observability_config=observability_config,
|
|
143
|
+
**kwargs,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
def _create_pool(self) -> "PyMysqlConnectionPool":
|
|
147
|
+
config = dict(self.connection_config)
|
|
148
|
+
pool_recycle = config.pop("pool_recycle_seconds", 86400)
|
|
149
|
+
health_check = config.pop("health_check_interval", 30.0)
|
|
150
|
+
extra = config.pop("extra", {})
|
|
151
|
+
config.update(extra)
|
|
152
|
+
return PyMysqlConnectionPool(config, recycle_seconds=pool_recycle, health_check_interval=health_check)
|
|
153
|
+
|
|
154
|
+
def _close_pool(self) -> None:
|
|
155
|
+
if self.connection_instance:
|
|
156
|
+
self.connection_instance.close()
|
|
157
|
+
|
|
158
|
+
def create_connection(self) -> PyMysqlConnection:
|
|
159
|
+
pool = self.provide_pool()
|
|
160
|
+
return pool.acquire()
|
|
161
|
+
|
|
162
|
+
def provide_connection(self, *args: Any, **kwargs: Any) -> "PyMysqlConnectionContext":
|
|
163
|
+
return PyMysqlConnectionContext(self)
|
|
164
|
+
|
|
165
|
+
def provide_session(
|
|
166
|
+
self, *_args: Any, statement_config: "StatementConfig | None" = None, **_kwargs: Any
|
|
167
|
+
) -> "PyMysqlSessionContext":
|
|
168
|
+
handler = _PyMysqlSessionConnectionHandler(self)
|
|
169
|
+
|
|
170
|
+
return PyMysqlSessionContext(
|
|
171
|
+
acquire_connection=handler.acquire_connection,
|
|
172
|
+
release_connection=handler.release_connection,
|
|
173
|
+
statement_config=statement_config or self.statement_config or default_statement_config,
|
|
174
|
+
driver_features=self.driver_features,
|
|
175
|
+
prepare_driver=self._prepare_driver,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
def get_signature_namespace(self) -> "dict[str, Any]":
|
|
179
|
+
namespace = super().get_signature_namespace()
|
|
180
|
+
namespace.update({
|
|
181
|
+
"PyMysqlConnectionContext": PyMysqlConnectionContext,
|
|
182
|
+
"PyMysqlConnection": PyMysqlConnection,
|
|
183
|
+
"PyMysqlConnectionParams": PyMysqlConnectionParams,
|
|
184
|
+
"PyMysqlConnectionPool": PyMysqlConnectionPool,
|
|
185
|
+
"PyMysqlCursor": PyMysqlCursor,
|
|
186
|
+
"PyMysqlDriver": PyMysqlDriver,
|
|
187
|
+
"PyMysqlDriverFeatures": PyMysqlDriverFeatures,
|
|
188
|
+
"PyMysqlExceptionHandler": PyMysqlExceptionHandler,
|
|
189
|
+
"PyMysqlPoolParams": PyMysqlPoolParams,
|
|
190
|
+
"PyMysqlSessionContext": PyMysqlSessionContext,
|
|
191
|
+
})
|
|
192
|
+
return namespace
|
|
193
|
+
|
|
194
|
+
def get_event_runtime_hints(self) -> "EventRuntimeHints":
|
|
195
|
+
return EventRuntimeHints(poll_interval=0.25, lease_seconds=5, select_for_update=True, skip_locked=True)
|
|
Binary file
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"""PyMySQL 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 PyMySQL execute calls."""
|
|
73
|
+
return parameters or None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def normalize_execute_many_parameters(parameters: Any) -> Any:
|
|
77
|
+
"""Normalize parameters for PyMySQL executemany calls."""
|
|
78
|
+
if not parameters:
|
|
79
|
+
msg = "execute_many requires parameters"
|
|
80
|
+
raise ValueError(msg)
|
|
81
|
+
return parameters
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def build_profile() -> "DriverParameterProfile":
|
|
85
|
+
"""Create the PyMySQL driver parameter profile."""
|
|
86
|
+
|
|
87
|
+
return DriverParameterProfile(
|
|
88
|
+
name="PyMySQL",
|
|
89
|
+
default_style=ParameterStyle.QMARK,
|
|
90
|
+
supported_styles={ParameterStyle.QMARK, ParameterStyle.POSITIONAL_PYFORMAT},
|
|
91
|
+
default_execution_style=ParameterStyle.POSITIONAL_PYFORMAT,
|
|
92
|
+
supported_execution_styles={ParameterStyle.POSITIONAL_PYFORMAT},
|
|
93
|
+
has_native_list_expansion=False,
|
|
94
|
+
preserve_parameter_format=True,
|
|
95
|
+
needs_static_script_compilation=True,
|
|
96
|
+
allow_mixed_parameter_styles=False,
|
|
97
|
+
preserve_original_params_for_many=False,
|
|
98
|
+
json_serializer_strategy="helper",
|
|
99
|
+
custom_type_coercions={bool: _bool_to_int},
|
|
100
|
+
default_dialect="mysql",
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
driver_profile = build_profile()
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def build_statement_config(
|
|
108
|
+
*, json_serializer: "Callable[[Any], str] | None" = None, json_deserializer: "Callable[[str], Any] | None" = None
|
|
109
|
+
) -> "StatementConfig":
|
|
110
|
+
"""Construct the PyMySQL statement configuration with optional JSON codecs."""
|
|
111
|
+
serializer = json_serializer or to_json
|
|
112
|
+
deserializer = json_deserializer or from_json
|
|
113
|
+
profile = driver_profile
|
|
114
|
+
return build_statement_config_from_profile(
|
|
115
|
+
profile, statement_overrides={"dialect": "mysql"}, json_serializer=serializer, json_deserializer=deserializer
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
default_statement_config = build_statement_config()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def apply_driver_features(
|
|
123
|
+
statement_config: "StatementConfig", driver_features: "Mapping[str, Any] | None"
|
|
124
|
+
) -> "tuple[StatementConfig, dict[str, Any]]":
|
|
125
|
+
"""Apply PyMySQL driver feature defaults to statement config."""
|
|
126
|
+
features: dict[str, Any] = dict(driver_features) if driver_features else {}
|
|
127
|
+
json_serializer = features.setdefault("json_serializer", to_json)
|
|
128
|
+
json_deserializer = features.setdefault("json_deserializer", from_json)
|
|
129
|
+
|
|
130
|
+
if json_serializer is not None:
|
|
131
|
+
parameter_config = statement_config.parameter_config.with_json_serializers(
|
|
132
|
+
json_serializer, deserializer=json_deserializer
|
|
133
|
+
)
|
|
134
|
+
statement_config = statement_config.replace(parameter_config=parameter_config)
|
|
135
|
+
|
|
136
|
+
return statement_config, features
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _create_mysql_error(
|
|
140
|
+
error: Any, sqlstate: "str | None", code: "int | None", error_class: type[SQLSpecError], description: str
|
|
141
|
+
) -> SQLSpecError:
|
|
142
|
+
"""Create a MySQL error instance without raising it."""
|
|
143
|
+
code_str = f"[{sqlstate or code}]" if sqlstate or code else ""
|
|
144
|
+
msg = f"MySQL {description} {code_str}: {error}" if code_str else f"MySQL {description}: {error}"
|
|
145
|
+
exc = error_class(msg)
|
|
146
|
+
exc.__cause__ = error
|
|
147
|
+
return exc
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def create_mapped_exception(error: Any, *, logger: Any | None = None) -> "SQLSpecError | bool":
|
|
151
|
+
"""Map PyMySQL exceptions to SQLSpec errors.
|
|
152
|
+
|
|
153
|
+
This is a factory function that returns an exception instance rather than
|
|
154
|
+
raising. This pattern is more robust for use in __exit__ handlers and
|
|
155
|
+
avoids issues with exception control flow in different Python versions.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
error: The PyMySQL exception to map
|
|
159
|
+
logger: Optional logger for migration warnings
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
True to suppress expected migration errors, or a SQLSpec exception
|
|
163
|
+
"""
|
|
164
|
+
error_code = error.args[0] if len(getattr(error, "args", [])) >= 1 and isinstance(error.args[0], int) else None
|
|
165
|
+
sqlstate = error.sqlstate if has_sqlstate(error) and error.sqlstate is not None else None
|
|
166
|
+
|
|
167
|
+
if error_code in {1061, 1091}:
|
|
168
|
+
if logger is not None:
|
|
169
|
+
logger.warning("PyMySQL expected migration error (ignoring): %s", error)
|
|
170
|
+
return True
|
|
171
|
+
|
|
172
|
+
if sqlstate == "23505" or error_code == MYSQL_ER_DUP_ENTRY:
|
|
173
|
+
return _create_mysql_error(error, sqlstate, error_code, UniqueViolationError, "unique constraint violation")
|
|
174
|
+
if sqlstate == "23503" or error_code in {1216, 1217, 1451, 1452}:
|
|
175
|
+
return _create_mysql_error(
|
|
176
|
+
error, sqlstate, error_code, ForeignKeyViolationError, "foreign key constraint violation"
|
|
177
|
+
)
|
|
178
|
+
if sqlstate == "23502" or error_code in {1048, MYSQL_ER_NO_DEFAULT_FOR_FIELD}:
|
|
179
|
+
return _create_mysql_error(error, sqlstate, error_code, NotNullViolationError, "not-null constraint violation")
|
|
180
|
+
if sqlstate == "23514" or error_code == MYSQL_ER_CHECK_CONSTRAINT_VIOLATED:
|
|
181
|
+
return _create_mysql_error(error, sqlstate, error_code, CheckViolationError, "check constraint violation")
|
|
182
|
+
if sqlstate and sqlstate.startswith("23"):
|
|
183
|
+
return _create_mysql_error(error, sqlstate, error_code, IntegrityError, "integrity constraint violation")
|
|
184
|
+
if sqlstate and sqlstate.startswith("42"):
|
|
185
|
+
return _create_mysql_error(error, sqlstate, error_code, SQLParsingError, "SQL syntax error")
|
|
186
|
+
if sqlstate and sqlstate.startswith("08"):
|
|
187
|
+
return _create_mysql_error(error, sqlstate, error_code, DatabaseConnectionError, "connection error")
|
|
188
|
+
if sqlstate and sqlstate.startswith("40"):
|
|
189
|
+
return _create_mysql_error(error, sqlstate, error_code, TransactionError, "transaction error")
|
|
190
|
+
if sqlstate and sqlstate.startswith("22"):
|
|
191
|
+
return _create_mysql_error(error, sqlstate, error_code, DataError, "data error")
|
|
192
|
+
if error_code in {2002, 2003, 2005, 2006, 2013}:
|
|
193
|
+
return _create_mysql_error(error, sqlstate, error_code, DatabaseConnectionError, "connection error")
|
|
194
|
+
if error_code in {1205, 1213}:
|
|
195
|
+
return _create_mysql_error(error, sqlstate, error_code, TransactionError, "transaction error")
|
|
196
|
+
if error_code in range(1064, 1100):
|
|
197
|
+
return _create_mysql_error(error, sqlstate, error_code, SQLParsingError, "SQL syntax error")
|
|
198
|
+
return _create_mysql_error(error, sqlstate, error_code, SQLSpecError, "database error")
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def detect_json_columns(cursor: Any, json_type_codes: "set[int]") -> "list[int]":
|
|
202
|
+
"""Identify JSON column indexes from cursor metadata."""
|
|
203
|
+
if not has_cursor_metadata(cursor):
|
|
204
|
+
return []
|
|
205
|
+
description = cursor.description
|
|
206
|
+
if not description or not json_type_codes:
|
|
207
|
+
return []
|
|
208
|
+
|
|
209
|
+
json_indexes: list[int] = []
|
|
210
|
+
for index, column in enumerate(description):
|
|
211
|
+
if has_type_code(column):
|
|
212
|
+
type_code = column.type_code
|
|
213
|
+
elif isinstance(column, (tuple, list)) and len(column) > 1:
|
|
214
|
+
type_code = column[1]
|
|
215
|
+
else:
|
|
216
|
+
type_code = None
|
|
217
|
+
if type_code in json_type_codes:
|
|
218
|
+
json_indexes.append(index)
|
|
219
|
+
return json_indexes
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _deserialize_pymysql_json_rows(
|
|
223
|
+
column_names: "list[str]",
|
|
224
|
+
rows: "list[dict[str, Any]]",
|
|
225
|
+
json_indexes: "list[int]",
|
|
226
|
+
deserializer: "Callable[[Any], Any]",
|
|
227
|
+
*,
|
|
228
|
+
logger: Any | None = None,
|
|
229
|
+
) -> "list[dict[str, Any]]":
|
|
230
|
+
"""Apply JSON deserialization to selected columns."""
|
|
231
|
+
if not rows or not column_names or not json_indexes:
|
|
232
|
+
return rows
|
|
233
|
+
|
|
234
|
+
target_columns = [column_names[index] for index in json_indexes if index < len(column_names)]
|
|
235
|
+
if not target_columns:
|
|
236
|
+
return rows
|
|
237
|
+
|
|
238
|
+
for row in rows:
|
|
239
|
+
for column in target_columns:
|
|
240
|
+
if column not in row:
|
|
241
|
+
continue
|
|
242
|
+
raw_value = row[column]
|
|
243
|
+
if raw_value is None:
|
|
244
|
+
continue
|
|
245
|
+
if isinstance(raw_value, bytearray):
|
|
246
|
+
raw_value = bytes(raw_value)
|
|
247
|
+
if not isinstance(raw_value, (str, bytes)):
|
|
248
|
+
continue
|
|
249
|
+
try:
|
|
250
|
+
row[column] = deserializer(raw_value)
|
|
251
|
+
except Exception:
|
|
252
|
+
if logger is not None:
|
|
253
|
+
logger.debug("Failed to deserialize JSON column %s", column, exc_info=True)
|
|
254
|
+
return rows
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def collect_rows(
|
|
258
|
+
fetched_data: "Sequence[Any] | None",
|
|
259
|
+
description: "Sequence[Any] | None",
|
|
260
|
+
json_indexes: "list[int]",
|
|
261
|
+
deserializer: "Callable[[Any], Any]",
|
|
262
|
+
*,
|
|
263
|
+
logger: Any | None = None,
|
|
264
|
+
) -> "tuple[list[dict[str, Any]], list[str]]":
|
|
265
|
+
"""Collect PyMySQL rows into dictionaries with JSON decoding."""
|
|
266
|
+
if not description:
|
|
267
|
+
return [], []
|
|
268
|
+
column_names = [desc[0] for desc in description]
|
|
269
|
+
if not fetched_data:
|
|
270
|
+
return [], column_names
|
|
271
|
+
if not isinstance(fetched_data[0], dict):
|
|
272
|
+
rows = [dict(zip(column_names, row, strict=False)) for row in fetched_data]
|
|
273
|
+
else:
|
|
274
|
+
rows = [dict(row) for row in fetched_data]
|
|
275
|
+
rows = _deserialize_pymysql_json_rows(column_names, rows, json_indexes, deserializer, logger=logger)
|
|
276
|
+
return rows, column_names
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def resolve_rowcount(cursor: Any) -> int:
|
|
280
|
+
"""Resolve rowcount from a PyMySQL cursor."""
|
|
281
|
+
if not has_rowcount(cursor):
|
|
282
|
+
return 0
|
|
283
|
+
rowcount = cursor.rowcount
|
|
284
|
+
if isinstance(rowcount, int) and rowcount >= 0:
|
|
285
|
+
return rowcount
|
|
286
|
+
return 0
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def normalize_lastrowid(cursor: Any) -> int | None:
|
|
290
|
+
"""Normalize lastrowid for PyMySQL when rowcount indicates success."""
|
|
291
|
+
if not has_rowcount(cursor):
|
|
292
|
+
return None
|
|
293
|
+
rowcount = cursor.rowcount
|
|
294
|
+
if not isinstance(rowcount, int) or rowcount <= 0:
|
|
295
|
+
return None
|
|
296
|
+
if not has_lastrowid(cursor):
|
|
297
|
+
return None
|
|
298
|
+
last_id = cursor.lastrowid
|
|
299
|
+
return last_id if isinstance(last_id, int) else None
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""MySQL-specific data dictionary for metadata queries via PyMySQL."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, ClassVar
|
|
4
|
+
|
|
5
|
+
from mypy_extensions import mypyc_attr
|
|
6
|
+
|
|
7
|
+
from sqlspec.driver import SyncDataDictionaryBase
|
|
8
|
+
from sqlspec.typing import ColumnMetadata, ForeignKeyMetadata, IndexMetadata, TableMetadata, VersionInfo
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from sqlspec.adapters.pymysql.driver import PyMysqlDriver
|
|
12
|
+
|
|
13
|
+
__all__ = ("PyMysqlDataDictionary",)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@mypyc_attr(allow_interpreted_subclasses=True, native_class=False)
|
|
17
|
+
class PyMysqlDataDictionary(SyncDataDictionaryBase):
|
|
18
|
+
"""MySQL-specific sync data dictionary."""
|
|
19
|
+
|
|
20
|
+
dialect: ClassVar[str] = "mysql"
|
|
21
|
+
|
|
22
|
+
def __init__(self) -> None:
|
|
23
|
+
super().__init__()
|
|
24
|
+
|
|
25
|
+
def get_version(self, driver: "PyMysqlDriver") -> "VersionInfo | None":
|
|
26
|
+
"""Get MySQL database version information."""
|
|
27
|
+
driver_id = id(driver)
|
|
28
|
+
# Inline cache check to avoid cross-module method call that causes mypyc segfault
|
|
29
|
+
if driver_id in self._version_fetch_attempted:
|
|
30
|
+
return self._version_cache.get(driver_id)
|
|
31
|
+
# Not cached, fetch from database
|
|
32
|
+
|
|
33
|
+
version_value = driver.select_value_or_none(self.get_query("version"))
|
|
34
|
+
if not version_value:
|
|
35
|
+
self._log_version_unavailable(type(self).dialect, "missing")
|
|
36
|
+
self.cache_version(driver_id, None)
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
version_info = self.parse_version_with_pattern(self.get_dialect_config().version_pattern, str(version_value))
|
|
40
|
+
if version_info is None:
|
|
41
|
+
self._log_version_unavailable(type(self).dialect, "parse_failed")
|
|
42
|
+
self.cache_version(driver_id, None)
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
self._log_version_detected(type(self).dialect, version_info)
|
|
46
|
+
self.cache_version(driver_id, version_info)
|
|
47
|
+
return version_info
|
|
48
|
+
|
|
49
|
+
def get_feature_flag(self, driver: "PyMysqlDriver", feature: str) -> bool:
|
|
50
|
+
"""Check if MySQL database supports a specific feature."""
|
|
51
|
+
version_info = self.get_version(driver)
|
|
52
|
+
return self.resolve_feature_flag(feature, version_info)
|
|
53
|
+
|
|
54
|
+
def get_optimal_type(self, driver: "PyMysqlDriver", type_category: str) -> str:
|
|
55
|
+
"""Get optimal MySQL type for a category."""
|
|
56
|
+
config = self.get_dialect_config()
|
|
57
|
+
version_info = self.get_version(driver)
|
|
58
|
+
|
|
59
|
+
if type_category == "json":
|
|
60
|
+
json_version = config.get_feature_version("supports_json")
|
|
61
|
+
if version_info and json_version and version_info >= json_version:
|
|
62
|
+
return "JSON"
|
|
63
|
+
return "TEXT"
|
|
64
|
+
|
|
65
|
+
return config.get_optimal_type(type_category)
|
|
66
|
+
|
|
67
|
+
def get_tables(self, driver: "PyMysqlDriver", schema: "str | None" = None) -> "list[TableMetadata]":
|
|
68
|
+
"""Get tables sorted by topological dependency order using the MySQL catalog."""
|
|
69
|
+
schema_name = self.resolve_schema(schema)
|
|
70
|
+
self._log_schema_introspect(driver, schema_name=schema_name, table_name=None, operation="tables")
|
|
71
|
+
return driver.select(self.get_query("tables_by_schema"), schema_name=schema_name, schema_type=TableMetadata)
|
|
72
|
+
|
|
73
|
+
def get_columns(
|
|
74
|
+
self, driver: "PyMysqlDriver", table: "str | None" = None, schema: "str | None" = None
|
|
75
|
+
) -> "list[ColumnMetadata]":
|
|
76
|
+
"""Get column information for a table or schema."""
|
|
77
|
+
schema_name = self.resolve_schema(schema)
|
|
78
|
+
if table is None:
|
|
79
|
+
self._log_schema_introspect(driver, schema_name=schema_name, table_name=None, operation="columns")
|
|
80
|
+
return driver.select(
|
|
81
|
+
self.get_query("columns_by_schema"), schema_name=schema_name, schema_type=ColumnMetadata
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
self._log_table_describe(driver, schema_name=schema_name, table_name=table, operation="columns")
|
|
85
|
+
return driver.select(
|
|
86
|
+
self.get_query("columns_by_table"), table_name=table, schema_name=schema_name, schema_type=ColumnMetadata
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def get_indexes(
|
|
90
|
+
self, driver: "PyMysqlDriver", table: "str | None" = None, schema: "str | None" = None
|
|
91
|
+
) -> "list[IndexMetadata]":
|
|
92
|
+
"""Get index metadata for a table or schema."""
|
|
93
|
+
schema_name = self.resolve_schema(schema)
|
|
94
|
+
if table is None:
|
|
95
|
+
self._log_schema_introspect(driver, schema_name=schema_name, table_name=None, operation="indexes")
|
|
96
|
+
return driver.select(
|
|
97
|
+
self.get_query("indexes_by_schema"), schema_name=schema_name, schema_type=IndexMetadata
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
self._log_table_describe(driver, schema_name=schema_name, table_name=table, operation="indexes")
|
|
101
|
+
return driver.select(
|
|
102
|
+
self.get_query("indexes_by_table"), table_name=table, schema_name=schema_name, schema_type=IndexMetadata
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
def get_foreign_keys(
|
|
106
|
+
self, driver: "PyMysqlDriver", table: "str | None" = None, schema: "str | None" = None
|
|
107
|
+
) -> "list[ForeignKeyMetadata]":
|
|
108
|
+
"""Get foreign key metadata."""
|
|
109
|
+
schema_name = self.resolve_schema(schema)
|
|
110
|
+
if table is None:
|
|
111
|
+
self._log_schema_introspect(driver, schema_name=schema_name, table_name=None, operation="foreign_keys")
|
|
112
|
+
return driver.select(
|
|
113
|
+
self.get_query("foreign_keys_by_schema"), schema_name=schema_name, schema_type=ForeignKeyMetadata
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
self._log_table_describe(driver, schema_name=schema_name, table_name=table, operation="foreign_keys")
|
|
117
|
+
return driver.select(
|
|
118
|
+
self.get_query("foreign_keys_by_table"),
|
|
119
|
+
table_name=table,
|
|
120
|
+
schema_name=schema_name,
|
|
121
|
+
schema_type=ForeignKeyMetadata,
|
|
122
|
+
)
|