sqlspec 0.72.0__cp315-cp315-win_amd64.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.
- 6b29784d6b1cafc66758__mypyc.cp315-win_amd64.pyd +0 -0
- sqlspec/__init__.py +381 -0
- sqlspec/__main__.py +14 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_typing.py +775 -0
- sqlspec/adapters/__init__.py +3 -0
- sqlspec/adapters/adbc/__init__.py +16 -0
- sqlspec/adapters/adbc/_typing.py +221 -0
- sqlspec/adapters/adbc/adk/__init__.py +11 -0
- sqlspec/adapters/adbc/adk/store.py +4101 -0
- sqlspec/adapters/adbc/config.py +843 -0
- sqlspec/adapters/adbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/core.py +3209 -0
- sqlspec/adapters/adbc/data_dictionary.py +1448 -0
- sqlspec/adapters/adbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/driver.py +1400 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +384 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +962 -0
- sqlspec/adapters/adbc/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/pool.py +242 -0
- sqlspec/adapters/adbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/type_converter.py +117 -0
- sqlspec/adapters/aiomysql/__init__.py +25 -0
- sqlspec/adapters/aiomysql/_typing.py +134 -0
- sqlspec/adapters/aiomysql/adk/__init__.py +5 -0
- sqlspec/adapters/aiomysql/adk/store.py +1542 -0
- sqlspec/adapters/aiomysql/config.py +634 -0
- sqlspec/adapters/aiomysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/core.py +922 -0
- sqlspec/adapters/aiomysql/data_dictionary.py +16 -0
- sqlspec/adapters/aiomysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/driver.py +494 -0
- sqlspec/adapters/aiomysql/events/__init__.py +5 -0
- sqlspec/adapters/aiomysql/events/store.py +72 -0
- sqlspec/adapters/aiomysql/litestar/__init__.py +5 -0
- sqlspec/adapters/aiomysql/litestar/store.py +345 -0
- sqlspec/adapters/aiosqlite/__init__.py +43 -0
- sqlspec/adapters/aiosqlite/_typing.py +75 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +1546 -0
- sqlspec/adapters/aiosqlite/config.py +607 -0
- sqlspec/adapters/aiosqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/core.py +1155 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +343 -0
- sqlspec/adapters/aiosqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/driver.py +559 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +54 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +315 -0
- sqlspec/adapters/aiosqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/pool.py +1323 -0
- sqlspec/adapters/aiosqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/type_converter.py +114 -0
- sqlspec/adapters/arrow_odbc/__init__.py +32 -0
- sqlspec/adapters/arrow_odbc/_typing.py +131 -0
- sqlspec/adapters/arrow_odbc/adk/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/adk/store.py +1671 -0
- sqlspec/adapters/arrow_odbc/config.py +446 -0
- sqlspec/adapters/arrow_odbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/core.py +795 -0
- sqlspec/adapters/arrow_odbc/data_dictionary.py +345 -0
- sqlspec/adapters/arrow_odbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/driver.py +885 -0
- sqlspec/adapters/arrow_odbc/events/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/events/store.py +114 -0
- sqlspec/adapters/arrow_odbc/litestar/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/litestar/store.py +682 -0
- sqlspec/adapters/arrow_odbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/type_converter.py +95 -0
- sqlspec/adapters/asyncmy/__init__.py +27 -0
- sqlspec/adapters/asyncmy/_typing.py +215 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +1544 -0
- sqlspec/adapters/asyncmy/config.py +707 -0
- sqlspec/adapters/asyncmy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/core.py +917 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +16 -0
- sqlspec/adapters/asyncmy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/driver.py +529 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +72 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +348 -0
- sqlspec/adapters/asyncpg/__init__.py +28 -0
- sqlspec/adapters/asyncpg/_typing.py +113 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +1145 -0
- sqlspec/adapters/asyncpg/config.py +903 -0
- sqlspec/adapters/asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/core.py +797 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +417 -0
- sqlspec/adapters/asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/driver.py +927 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/events/_hub.py +279 -0
- sqlspec/adapters/asyncpg/events/backend.py +410 -0
- sqlspec/adapters/asyncpg/events/store.py +57 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +278 -0
- sqlspec/adapters/asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/tenant.py +140 -0
- sqlspec/adapters/bigquery/__init__.py +23 -0
- sqlspec/adapters/bigquery/_typing.py +184 -0
- sqlspec/adapters/bigquery/adk/__init__.py +5 -0
- sqlspec/adapters/bigquery/adk/store.py +920 -0
- sqlspec/adapters/bigquery/config.py +631 -0
- sqlspec/adapters/bigquery/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/core.py +1433 -0
- sqlspec/adapters/bigquery/data_dictionary.py +502 -0
- sqlspec/adapters/bigquery/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/driver.py +1266 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +158 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +359 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +32 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +54 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +9 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +1096 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +653 -0
- sqlspec/adapters/cockroach_asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +835 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +371 -0
- sqlspec/adapters/cockroach_asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +438 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +203 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.py +143 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +46 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +271 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +2274 -0
- sqlspec/adapters/cockroach_psycopg/config.py +1285 -0
- sqlspec/adapters/cockroach_psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +667 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +622 -0
- sqlspec/adapters/cockroach_psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +864 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +8 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +9 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +413 -0
- sqlspec/adapters/cockroach_psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/tenant.py +222 -0
- sqlspec/adapters/db2/__init__.py +34 -0
- sqlspec/adapters/db2/_typing.py +357 -0
- sqlspec/adapters/db2/adk/__init__.py +10 -0
- sqlspec/adapters/db2/adk/store.py +1950 -0
- sqlspec/adapters/db2/config.py +550 -0
- sqlspec/adapters/db2/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/core.py +1021 -0
- sqlspec/adapters/db2/data_dictionary.py +493 -0
- sqlspec/adapters/db2/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/driver.py +898 -0
- sqlspec/adapters/db2/events/__init__.py +5 -0
- sqlspec/adapters/db2/events/store.py +77 -0
- sqlspec/adapters/db2/litestar/__init__.py +5 -0
- sqlspec/adapters/db2/litestar/store.py +519 -0
- sqlspec/adapters/db2/migrations.py +221 -0
- sqlspec/adapters/db2/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/pool.py +876 -0
- sqlspec/adapters/db2/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/tenant.py +292 -0
- sqlspec/adapters/duckdb/__init__.py +30 -0
- sqlspec/adapters/duckdb/_typing.py +182 -0
- sqlspec/adapters/duckdb/adk/__init__.py +10 -0
- sqlspec/adapters/duckdb/adk/store.py +1672 -0
- sqlspec/adapters/duckdb/config.py +506 -0
- sqlspec/adapters/duckdb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/core.py +1299 -0
- sqlspec/adapters/duckdb/data_dictionary.py +553 -0
- sqlspec/adapters/duckdb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/driver.py +1214 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +38 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +313 -0
- sqlspec/adapters/duckdb/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/pool.py +1121 -0
- sqlspec/adapters/mssql_python/__init__.py +42 -0
- sqlspec/adapters/mssql_python/_typing.py +135 -0
- sqlspec/adapters/mssql_python/adk/__init__.py +5 -0
- sqlspec/adapters/mssql_python/adk/store.py +1278 -0
- sqlspec/adapters/mssql_python/config.py +455 -0
- sqlspec/adapters/mssql_python/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/core.py +862 -0
- sqlspec/adapters/mssql_python/data_dictionary.py +417 -0
- sqlspec/adapters/mssql_python/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/driver.py +772 -0
- sqlspec/adapters/mssql_python/events/__init__.py +5 -0
- sqlspec/adapters/mssql_python/events/store.py +46 -0
- sqlspec/adapters/mssql_python/litestar/__init__.py +5 -0
- sqlspec/adapters/mssql_python/litestar/store.py +355 -0
- sqlspec/adapters/mssql_python/migrations.py +162 -0
- sqlspec/adapters/mssql_python/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/pool.py +165 -0
- sqlspec/adapters/mssql_python/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/tenant.py +74 -0
- sqlspec/adapters/mssql_python/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/type_converter.py +98 -0
- sqlspec/adapters/mysqlconnector/__init__.py +47 -0
- sqlspec/adapters/mysqlconnector/_typing.py +205 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +17 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +2503 -0
- sqlspec/adapters/mysqlconnector/config.py +925 -0
- sqlspec/adapters/mysqlconnector/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/core.py +1075 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +23 -0
- sqlspec/adapters/mysqlconnector/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/driver.py +702 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +89 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +9 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +524 -0
- sqlspec/adapters/oracledb/__init__.py +159 -0
- sqlspec/adapters/oracledb/_json_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_json_handlers.py +208 -0
- sqlspec/adapters/oracledb/_param_types.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_param_types.py +65 -0
- sqlspec/adapters/oracledb/_plugins.py +137 -0
- sqlspec/adapters/oracledb/_storage.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_storage.py +138 -0
- sqlspec/adapters/oracledb/_typing.py +468 -0
- sqlspec/adapters/oracledb/_uuid_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +143 -0
- sqlspec/adapters/oracledb/_vector_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_vector_handlers.py +252 -0
- sqlspec/adapters/oracledb/adk/__init__.py +27 -0
- sqlspec/adapters/oracledb/adk/store.py +4031 -0
- sqlspec/adapters/oracledb/config.py +1785 -0
- sqlspec/adapters/oracledb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/core.py +5416 -0
- sqlspec/adapters/oracledb/data_dictionary.py +1264 -0
- sqlspec/adapters/oracledb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/driver.py +3273 -0
- sqlspec/adapters/oracledb/events/__init__.py +29 -0
- sqlspec/adapters/oracledb/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/events/_hub.py +394 -0
- sqlspec/adapters/oracledb/events/backend.py +311 -0
- sqlspec/adapters/oracledb/events/store.py +842 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +17 -0
- sqlspec/adapters/oracledb/litestar/store.py +862 -0
- sqlspec/adapters/oracledb/migrations.py +650 -0
- sqlspec/adapters/oracledb/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/tenant.py +990 -0
- sqlspec/adapters/oracledb/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/type_converter.py +93 -0
- sqlspec/adapters/psqlpy/__init__.py +21 -0
- sqlspec/adapters/psqlpy/_typing.py +180 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +1514 -0
- sqlspec/adapters/psqlpy/config.py +828 -0
- sqlspec/adapters/psqlpy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/core.py +1040 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +399 -0
- sqlspec/adapters/psqlpy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/driver.py +631 -0
- sqlspec/adapters/psqlpy/events/__init__.py +12 -0
- sqlspec/adapters/psqlpy/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/events/_hub.py +367 -0
- sqlspec/adapters/psqlpy/events/backend.py +415 -0
- sqlspec/adapters/psqlpy/events/store.py +46 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/tenant.py +137 -0
- sqlspec/adapters/psqlpy/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +21 -0
- sqlspec/adapters/psycopg/__init__.py +44 -0
- sqlspec/adapters/psycopg/_typing.py +408 -0
- sqlspec/adapters/psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/psycopg/adk/store.py +2761 -0
- sqlspec/adapters/psycopg/config.py +1522 -0
- sqlspec/adapters/psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/core.py +1001 -0
- sqlspec/adapters/psycopg/data_dictionary.py +701 -0
- sqlspec/adapters/psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/driver.py +1629 -0
- sqlspec/adapters/psycopg/events/__init__.py +25 -0
- sqlspec/adapters/psycopg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/events/_hub.py +646 -0
- sqlspec/adapters/psycopg/events/backend.py +739 -0
- sqlspec/adapters/psycopg/events/store.py +82 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +595 -0
- sqlspec/adapters/psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/tenant.py +226 -0
- sqlspec/adapters/psycopg/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/type_converter.py +94 -0
- sqlspec/adapters/pymssql/__init__.py +29 -0
- sqlspec/adapters/pymssql/_typing.py +156 -0
- sqlspec/adapters/pymssql/adk/__init__.py +5 -0
- sqlspec/adapters/pymssql/adk/store.py +1270 -0
- sqlspec/adapters/pymssql/config.py +299 -0
- sqlspec/adapters/pymssql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/core.py +527 -0
- sqlspec/adapters/pymssql/data_dictionary.py +417 -0
- sqlspec/adapters/pymssql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/driver.py +527 -0
- sqlspec/adapters/pymssql/events/__init__.py +5 -0
- sqlspec/adapters/pymssql/events/store.py +46 -0
- sqlspec/adapters/pymssql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymssql/litestar/store.py +350 -0
- sqlspec/adapters/pymssql/migrations.py +162 -0
- sqlspec/adapters/pymssql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/pool.py +417 -0
- sqlspec/adapters/pymssql/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/tenant.py +73 -0
- sqlspec/adapters/pymysql/__init__.py +27 -0
- sqlspec/adapters/pymysql/_typing.py +105 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +1646 -0
- sqlspec/adapters/pymysql/config.py +545 -0
- sqlspec/adapters/pymysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/core.py +909 -0
- sqlspec/adapters/pymysql/data_dictionary.py +16 -0
- sqlspec/adapters/pymysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/driver.py +370 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +42 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +299 -0
- sqlspec/adapters/pymysql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/pool.py +480 -0
- sqlspec/adapters/snowflake/__init__.py +36 -0
- sqlspec/adapters/snowflake/_typing.py +62 -0
- sqlspec/adapters/snowflake/adk/__init__.py +5 -0
- sqlspec/adapters/snowflake/adk/store.py +778 -0
- sqlspec/adapters/snowflake/config.py +333 -0
- sqlspec/adapters/snowflake/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/core.py +683 -0
- sqlspec/adapters/snowflake/data_dictionary.py +355 -0
- sqlspec/adapters/snowflake/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/driver.py +872 -0
- sqlspec/adapters/snowflake/events/__init__.py +5 -0
- sqlspec/adapters/snowflake/events/store.py +28 -0
- sqlspec/adapters/snowflake/litestar/__init__.py +5 -0
- sqlspec/adapters/snowflake/litestar/store.py +162 -0
- sqlspec/adapters/snowflake/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/migrations.py +76 -0
- sqlspec/adapters/snowflake/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/pool.py +385 -0
- sqlspec/adapters/snowflake/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/tenant.py +200 -0
- sqlspec/adapters/snowflake/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/type_converter.py +33 -0
- sqlspec/adapters/spanner/__init__.py +57 -0
- sqlspec/adapters/spanner/_typing.py +300 -0
- sqlspec/adapters/spanner/adk/__init__.py +22 -0
- sqlspec/adapters/spanner/adk/artifact_store.py +693 -0
- sqlspec/adapters/spanner/adk/store.py +3053 -0
- sqlspec/adapters/spanner/config.py +1578 -0
- sqlspec/adapters/spanner/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/core.py +1244 -0
- sqlspec/adapters/spanner/data_dictionary.py +706 -0
- sqlspec/adapters/spanner/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/driver.py +1673 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +357 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +570 -0
- sqlspec/adapters/spanner/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/type_converter.py +466 -0
- sqlspec/adapters/sqlanywhere/__init__.py +40 -0
- sqlspec/adapters/sqlanywhere/_typing.py +139 -0
- sqlspec/adapters/sqlanywhere/adk/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/adk/store.py +1136 -0
- sqlspec/adapters/sqlanywhere/config.py +359 -0
- sqlspec/adapters/sqlanywhere/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/core.py +583 -0
- sqlspec/adapters/sqlanywhere/data_dictionary.py +282 -0
- sqlspec/adapters/sqlanywhere/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/driver.py +480 -0
- sqlspec/adapters/sqlanywhere/events/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/events/store.py +28 -0
- sqlspec/adapters/sqlanywhere/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/litestar/store.py +237 -0
- sqlspec/adapters/sqlanywhere/migrations.py +178 -0
- sqlspec/adapters/sqlanywhere/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/pool.py +397 -0
- sqlspec/adapters/sqlite/__init__.py +32 -0
- sqlspec/adapters/sqlite/_typing.py +91 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +1628 -0
- sqlspec/adapters/sqlite/config.py +520 -0
- sqlspec/adapters/sqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/core.py +1035 -0
- sqlspec/adapters/sqlite/data_dictionary.py +327 -0
- sqlspec/adapters/sqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/driver.py +432 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +54 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +367 -0
- sqlspec/adapters/sqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/pool.py +935 -0
- sqlspec/adapters/sqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/adapters/sybase/__init__.py +37 -0
- sqlspec/adapters/sybase/_typing.py +150 -0
- sqlspec/adapters/sybase/adk/__init__.py +5 -0
- sqlspec/adapters/sybase/adk/store.py +1370 -0
- sqlspec/adapters/sybase/config.py +276 -0
- sqlspec/adapters/sybase/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/core.py +578 -0
- sqlspec/adapters/sybase/data_dictionary.py +358 -0
- sqlspec/adapters/sybase/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/driver.py +497 -0
- sqlspec/adapters/sybase/events/__init__.py +5 -0
- sqlspec/adapters/sybase/events/store.py +88 -0
- sqlspec/adapters/sybase/litestar/__init__.py +5 -0
- sqlspec/adapters/sybase/litestar/store.py +328 -0
- sqlspec/adapters/sybase/migrations.py +178 -0
- sqlspec/adapters/sybase/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/pool.py +435 -0
- sqlspec/adapters/teradata/__init__.py +59 -0
- sqlspec/adapters/teradata/_typing.py +145 -0
- sqlspec/adapters/teradata/adk/__init__.py +5 -0
- sqlspec/adapters/teradata/adk/store.py +1300 -0
- sqlspec/adapters/teradata/config.py +324 -0
- sqlspec/adapters/teradata/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/core.py +437 -0
- sqlspec/adapters/teradata/data_dictionary.py +316 -0
- sqlspec/adapters/teradata/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/driver.py +721 -0
- sqlspec/adapters/teradata/events/__init__.py +5 -0
- sqlspec/adapters/teradata/events/store.py +64 -0
- sqlspec/adapters/teradata/litestar/__init__.py +5 -0
- sqlspec/adapters/teradata/litestar/store.py +264 -0
- sqlspec/adapters/teradata/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/migrations.py +80 -0
- sqlspec/adapters/teradata/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/pool.py +377 -0
- sqlspec/adapters/teradata/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/type_converter.py +95 -0
- sqlspec/base.cp315-win_amd64.pyd +0 -0
- sqlspec/base.py +1275 -0
- sqlspec/builder/__init__.py +330 -0
- sqlspec/builder/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_base.py +1752 -0
- sqlspec/builder/_column.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_column.py +508 -0
- sqlspec/builder/_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_ddl.py +4503 -0
- sqlspec/builder/_delete.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_delete.py +75 -0
- sqlspec/builder/_dml.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_dml.py +639 -0
- sqlspec/builder/_explain.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_explain.py +650 -0
- sqlspec/builder/_expression_wrappers.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_expression_wrappers.py +77 -0
- sqlspec/builder/_factory.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_factory.py +1834 -0
- sqlspec/builder/_generation.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_generation.py +55 -0
- sqlspec/builder/_insert.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_insert.py +308 -0
- sqlspec/builder/_join.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_join.py +501 -0
- sqlspec/builder/_locking.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_locking.py +77 -0
- sqlspec/builder/_merge.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_merge.py +1047 -0
- sqlspec/builder/_parsing_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_parsing_utils.py +1197 -0
- sqlspec/builder/_select.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_select.py +1514 -0
- sqlspec/builder/_temporal.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_temporal.py +183 -0
- sqlspec/builder/_update.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_update.py +139 -0
- sqlspec/builder/_values.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_values.py +271 -0
- sqlspec/builder/_vector_distance.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_vector_distance.py +763 -0
- sqlspec/cli.py +1656 -0
- sqlspec/config.py +3402 -0
- sqlspec/core/__init__.py +542 -0
- sqlspec/core/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_cursor.py +564 -0
- sqlspec/core/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_operators.py +167 -0
- sqlspec/core/_ordering.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_ordering.py +151 -0
- sqlspec/core/_pagination.py +66 -0
- sqlspec/core/_pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pipeline.py +343 -0
- sqlspec/core/_pool.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pool.py +72 -0
- sqlspec/core/cache.cp315-win_amd64.pyd +0 -0
- sqlspec/core/cache.py +1503 -0
- sqlspec/core/capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/core/capabilities.py +67 -0
- sqlspec/core/compiler.cp315-win_amd64.pyd +0 -0
- sqlspec/core/compiler.py +1667 -0
- sqlspec/core/config_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/core/config_runtime.py +219 -0
- sqlspec/core/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/core/correlation.py +135 -0
- sqlspec/core/explain.cp315-win_amd64.pyd +0 -0
- sqlspec/core/explain.py +284 -0
- sqlspec/core/filters.cp315-win_amd64.pyd +0 -0
- sqlspec/core/filters.py +1442 -0
- sqlspec/core/hashing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/hashing.py +394 -0
- sqlspec/core/metrics.cp315-win_amd64.pyd +0 -0
- sqlspec/core/metrics.py +86 -0
- sqlspec/core/parameters/__init__.py +174 -0
- sqlspec/core/parameters/_alignment.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_alignment.py +321 -0
- sqlspec/core/parameters/_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_converter.py +956 -0
- sqlspec/core/parameters/_declared.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_declared.py +154 -0
- sqlspec/core/parameters/_processor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_processor.py +1646 -0
- sqlspec/core/parameters/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_registry.py +207 -0
- sqlspec/core/parameters/_transformers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_transformers.py +318 -0
- sqlspec/core/parameters/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_types.py +658 -0
- sqlspec/core/parameters/_validator.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_validator.py +699 -0
- sqlspec/core/query_modifiers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/query_modifiers.py +559 -0
- sqlspec/core/result/__init__.py +67 -0
- sqlspec/core/result/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/result/_base.py +1772 -0
- sqlspec/core/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/routing.py +270 -0
- sqlspec/core/splitter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/splitter.py +1126 -0
- sqlspec/core/sqlcommenter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/sqlcommenter.py +509 -0
- sqlspec/core/stack.cp315-win_amd64.pyd +0 -0
- sqlspec/core/stack.py +167 -0
- sqlspec/core/statement.cp315-win_amd64.pyd +0 -0
- sqlspec/core/statement.py +2253 -0
- sqlspec/core/tenant/__init__.py +64 -0
- sqlspec/core/tenant/base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/tenant/base.py +123 -0
- sqlspec/core/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/type_converter.py +147 -0
- sqlspec/data_dictionary/__init__.py +237 -0
- sqlspec/data_dictionary/_capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_capabilities.py +142 -0
- sqlspec/data_dictionary/_dependencies.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_dependencies.py +602 -0
- sqlspec/data_dictionary/_index_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_index_ddl.py +562 -0
- sqlspec/data_dictionary/_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_loader.py +344 -0
- sqlspec/data_dictionary/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_registry.py +152 -0
- sqlspec/data_dictionary/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_types.py +1852 -0
- sqlspec/data_dictionary/dialects/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/bigquery/__init__.py +15 -0
- sqlspec/data_dictionary/dialects/bigquery/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/bigquery/config.py +128 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/columns.sql +63 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/constraints.sql +37 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/datasets.sql +14 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/ddl.sql +51 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/dependencies.sql +22 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/indexes.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/routines.sql +50 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/system.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/tables.sql +111 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/views.sql +31 -0
- sqlspec/data_dictionary/dialects/cockroachdb/__init__.py +17 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.py +95 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/columns.sql +163 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/comments.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/crdb_internal.sql +11 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/ddl.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/dependencies.sql +20 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/foreign_keys.sql +62 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/indexes.sql +32 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/objects.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/tables.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/views.sql +11 -0
- sqlspec/data_dictionary/dialects/db2/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/db2/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/db2/config.py +172 -0
- sqlspec/data_dictionary/dialects/db2/sql/columns.sql +98 -0
- sqlspec/data_dictionary/dialects/db2/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/db2/sql/foreign_keys.sql +43 -0
- sqlspec/data_dictionary/dialects/db2/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/db2/sql/objects.sql +53 -0
- sqlspec/data_dictionary/dialects/db2/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/db2/sql/tables.sql +77 -0
- sqlspec/data_dictionary/dialects/db2/sql/version.sql +8 -0
- sqlspec/data_dictionary/dialects/db2/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/duckdb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/duckdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/duckdb/config.py +66 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/columns.sql +150 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/constraints.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/databases.sql +11 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/ddl.sql +221 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/dependencies.sql +50 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/extensions.sql +14 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/foreign_keys.sql +46 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/functions.sql +18 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/indexes.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/objects.sql +30 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/sequences.sql +19 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/system.sql +21 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/tables.sql +59 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/types.sql +12 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mariadb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/ddl.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/objects.sql +50 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/privileges.sql +24 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/system.sql +12 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mssql/__init__.py +51 -0
- sqlspec/data_dictionary/dialects/mssql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mssql/config.py +558 -0
- sqlspec/data_dictionary/dialects/mssql/sql/columns.sql +120 -0
- sqlspec/data_dictionary/dialects/mssql/sql/constraints.sql +106 -0
- sqlspec/data_dictionary/dialects/mssql/sql/ddl.sql +89 -0
- sqlspec/data_dictionary/dialects/mssql/sql/dependencies.sql +17 -0
- sqlspec/data_dictionary/dialects/mssql/sql/extended_properties.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/dialects/mssql/sql/indexes.sql +86 -0
- sqlspec/data_dictionary/dialects/mssql/sql/modules.sql +19 -0
- sqlspec/data_dictionary/dialects/mssql/sql/objects.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/permissions.sql +31 -0
- sqlspec/data_dictionary/dialects/mssql/sql/routines.sql +39 -0
- sqlspec/data_dictionary/dialects/mssql/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/mssql/sql/sequences.sql +18 -0
- sqlspec/data_dictionary/dialects/mssql/sql/storage.sql +22 -0
- sqlspec/data_dictionary/dialects/mssql/sql/system.sql +38 -0
- sqlspec/data_dictionary/dialects/mssql/sql/tables.sql +97 -0
- sqlspec/data_dictionary/dialects/mssql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mssql/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mssql/sql/views.sql +18 -0
- sqlspec/data_dictionary/dialects/mysql/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/mysql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mysql/config.py +363 -0
- sqlspec/data_dictionary/dialects/mysql/dictionary.py +650 -0
- sqlspec/data_dictionary/dialects/mysql/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mysql/sql/components.sql +8 -0
- sqlspec/data_dictionary/dialects/mysql/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mysql/sql/ddl.sql +23 -0
- sqlspec/data_dictionary/dialects/mysql/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mysql/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mysql/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mysql/sql/objects.sql +38 -0
- sqlspec/data_dictionary/dialects/mysql/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mysql/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mysql/sql/privileges.sql +26 -0
- sqlspec/data_dictionary/dialects/mysql/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mysql/sql/system.sql +25 -0
- sqlspec/data_dictionary/dialects/mysql/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mysql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/mysql/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/oracle/__init__.py +39 -0
- sqlspec/data_dictionary/dialects/oracle/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/oracle/config.py +266 -0
- sqlspec/data_dictionary/dialects/oracle/sql/arguments.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/columns.sql +103 -0
- sqlspec/data_dictionary/dialects/oracle/sql/comments.sql +22 -0
- sqlspec/data_dictionary/dialects/oracle/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/oracle/sql/ddl.sql +4 -0
- sqlspec/data_dictionary/dialects/oracle/sql/dependencies.sql +16 -0
- sqlspec/data_dictionary/dialects/oracle/sql/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/grants.sql +34 -0
- sqlspec/data_dictionary/dialects/oracle/sql/indexes.sql +87 -0
- sqlspec/data_dictionary/dialects/oracle/sql/lob_storage.sql +28 -0
- sqlspec/data_dictionary/dialects/oracle/sql/materialized_views.sql +27 -0
- sqlspec/data_dictionary/dialects/oracle/sql/objects.sql +26 -0
- sqlspec/data_dictionary/dialects/oracle/sql/partitions.sql +44 -0
- sqlspec/data_dictionary/dialects/oracle/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/sequences.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/source.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/system.sql +37 -0
- sqlspec/data_dictionary/dialects/oracle/sql/tables.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/triggers.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/version.sql +25 -0
- sqlspec/data_dictionary/dialects/oracle/sql/views.sql +49 -0
- sqlspec/data_dictionary/dialects/postgres/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/postgres/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/postgres/config.py +119 -0
- sqlspec/data_dictionary/dialects/postgres/sql/columns.sql +130 -0
- sqlspec/data_dictionary/dialects/postgres/sql/comments.sql +27 -0
- sqlspec/data_dictionary/dialects/postgres/sql/constraints.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/ddl.sql +55 -0
- sqlspec/data_dictionary/dialects/postgres/sql/dependencies.sql +42 -0
- sqlspec/data_dictionary/dialects/postgres/sql/extensions.sql +11 -0
- sqlspec/data_dictionary/dialects/postgres/sql/foreign_keys.sql +72 -0
- sqlspec/data_dictionary/dialects/postgres/sql/indexes.sql +84 -0
- sqlspec/data_dictionary/dialects/postgres/sql/materialized_views.sql +17 -0
- sqlspec/data_dictionary/dialects/postgres/sql/objects.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/partitions.sql +19 -0
- sqlspec/data_dictionary/dialects/postgres/sql/privileges.sql +29 -0
- sqlspec/data_dictionary/dialects/postgres/sql/routines.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/postgres/sql/sequences.sql +32 -0
- sqlspec/data_dictionary/dialects/postgres/sql/system.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/tables.sql +67 -0
- sqlspec/data_dictionary/dialects/postgres/sql/triggers.sql +20 -0
- sqlspec/data_dictionary/dialects/postgres/sql/types.sql +21 -0
- sqlspec/data_dictionary/dialects/postgres/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/postgres/sql/views.sql +17 -0
- sqlspec/data_dictionary/dialects/snowflake/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/snowflake/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/snowflake/config.py +321 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/columns.sql +48 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/constraints.sql +64 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/ddl.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/foreign_keys.sql +7 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/objects.sql +34 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/routines.sql +79 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/schemas.sql +19 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/sequences.sql +45 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/tables.sql +29 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/views.sql +37 -0
- sqlspec/data_dictionary/dialects/spanner/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/spanner/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/spanner/config.py +67 -0
- sqlspec/data_dictionary/dialects/spanner/sql/columns.sql +58 -0
- sqlspec/data_dictionary/dialects/spanner/sql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/columns.sql +46 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/database.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/indexes.sql +66 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/placements.sql +8 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/property_graphs.sql +11 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/routines.sql +33 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/tables.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/views.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/indexes.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/columns.sql +34 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/indexes.sql +52 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/spanner/sql/tables.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.py +191 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/columns.sql +97 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/constraints.sql +43 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/objects.sql +18 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/schemas.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/tables.sql +86 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlite/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/sqlite/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlite/config.py +412 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/columns.sql +59 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/compile_options.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/ddl.sql +37 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/functions.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/indexes.sql +76 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/modules.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/schemas.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/system.sql +7 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/triggers.sql +10 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/views.sql +10 -0
- sqlspec/data_dictionary/dialects/sybase/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sybase/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sybase/config.py +187 -0
- sqlspec/data_dictionary/dialects/sybase/sql/columns.sql +137 -0
- sqlspec/data_dictionary/dialects/sybase/sql/constraints.sql +85 -0
- sqlspec/data_dictionary/dialects/sybase/sql/foreign_keys.sql +81 -0
- sqlspec/data_dictionary/dialects/sybase/sql/indexes.sql +51 -0
- sqlspec/data_dictionary/dialects/sybase/sql/objects.sql +21 -0
- sqlspec/data_dictionary/dialects/sybase/sql/schemas.sql +16 -0
- sqlspec/data_dictionary/dialects/sybase/sql/tables.sql +46 -0
- sqlspec/data_dictionary/dialects/sybase/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sybase/sql/views.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/__init__.py +33 -0
- sqlspec/data_dictionary/dialects/teradata/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/teradata/config.py +228 -0
- sqlspec/data_dictionary/dialects/teradata/sql/columns.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/constraints.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/sql/foreign_keys.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/indexes.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/objects.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/schemas.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/version.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/views.sql +4 -0
- sqlspec/dialects/__init__.py +44 -0
- sqlspec/dialects/db2/__init__.py +111 -0
- sqlspec/dialects/db2/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_generators.py +376 -0
- sqlspec/dialects/db2/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_parsers.py +657 -0
- sqlspec/dialects/db2/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_transforms.py +175 -0
- sqlspec/dialects/postgres/__init__.py +10 -0
- sqlspec/dialects/postgres/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_generators.py +81 -0
- sqlspec/dialects/postgres/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_operators.py +95 -0
- sqlspec/dialects/postgres/_paradedb.py +44 -0
- sqlspec/dialects/postgres/_pg_textsearch.py +38 -0
- sqlspec/dialects/postgres/_pgvector.py +36 -0
- sqlspec/dialects/spanner/__init__.py +69 -0
- sqlspec/dialects/spanner/_expressions.py +247 -0
- sqlspec/dialects/spanner/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_generators.py +961 -0
- sqlspec/dialects/spanner/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_parsers.py +871 -0
- sqlspec/dialects/spanner/_spangres.py +43 -0
- sqlspec/dialects/spanner/_spanner.py +57 -0
- sqlspec/dialects/sybase/__init__.py +115 -0
- sqlspec/dialects/sybase/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_generators.py +379 -0
- sqlspec/dialects/sybase/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_parsers.py +225 -0
- sqlspec/dialects/sybase/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_transforms.py +68 -0
- sqlspec/dialects/teradata/__init__.py +42 -0
- sqlspec/dialects/teradata/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/teradata/_generators.py +203 -0
- sqlspec/driver/__init__.py +151 -0
- sqlspec/driver/_async.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_async.py +3244 -0
- sqlspec/driver/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_common.py +4765 -0
- sqlspec/driver/_deferred.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_deferred.py +232 -0
- sqlspec/driver/_exception_handler.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_exception_handler.py +224 -0
- sqlspec/driver/_routing.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_routing.py +2891 -0
- sqlspec/driver/_session.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_session.py +180 -0
- sqlspec/driver/_sql_helpers.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sql_helpers.py +140 -0
- sqlspec/driver/_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_stream.py +392 -0
- sqlspec/driver/_sync.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sync.py +3107 -0
- sqlspec/driver/_tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_tenant.py +326 -0
- sqlspec/exceptions.cp315-win_amd64.pyd +0 -0
- sqlspec/exceptions.py +568 -0
- sqlspec/extensions/__init__.py +3 -0
- sqlspec/extensions/adk/__init__.py +136 -0
- sqlspec/extensions/adk/_config_utils.py +306 -0
- sqlspec/extensions/adk/_table_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_table_utils.py +126 -0
- sqlspec/extensions/adk/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_types.py +59 -0
- sqlspec/extensions/adk/artifact/__init__.py +18 -0
- sqlspec/extensions/adk/artifact/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/artifact/_types.py +41 -0
- sqlspec/extensions/adk/artifact/service.py +657 -0
- sqlspec/extensions/adk/artifact/store.py +444 -0
- sqlspec/extensions/adk/converters.py +230 -0
- sqlspec/extensions/adk/maintenance.py +262 -0
- sqlspec/extensions/adk/memory/__init__.py +36 -0
- sqlspec/extensions/adk/memory/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/memory/_types.py +48 -0
- sqlspec/extensions/adk/memory/converters.py +271 -0
- sqlspec/extensions/adk/memory/service.py +474 -0
- sqlspec/extensions/adk/memory/store.py +586 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +181 -0
- sqlspec/extensions/adk/migrations/0002_create_mssql_python_memory.py +51 -0
- sqlspec/extensions/adk/migrations/__init__.py +3 -0
- sqlspec/extensions/adk/migrations/reconcile.py +282 -0
- sqlspec/extensions/adk/service.py +463 -0
- sqlspec/extensions/adk/store.py +1239 -0
- sqlspec/extensions/events/__init__.py +132 -0
- sqlspec/extensions/events/_buffer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_buffer.py +38 -0
- sqlspec/extensions/events/_channel.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_channel.py +1144 -0
- sqlspec/extensions/events/_hints.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_hints.py +38 -0
- sqlspec/extensions/events/_models.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_models.py +22 -0
- sqlspec/extensions/events/_names.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_names.py +27 -0
- sqlspec/extensions/events/_payload.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_payload.py +139 -0
- sqlspec/extensions/events/_protocols.py +154 -0
- sqlspec/extensions/events/_queue.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_queue.py +1147 -0
- sqlspec/extensions/events/_store.py +318 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +106 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/events/migrations/reconcile.py +145 -0
- sqlspec/extensions/events/primitives.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/primitives.py +91 -0
- sqlspec/extensions/fastapi/__init__.py +26 -0
- sqlspec/extensions/fastapi/extension.py +360 -0
- sqlspec/extensions/fastapi/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/fastapi/providers.py +1091 -0
- sqlspec/extensions/flask/__init__.py +20 -0
- sqlspec/extensions/flask/_portal.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_portal.py +212 -0
- sqlspec/extensions/flask/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_state.py +135 -0
- sqlspec/extensions/flask/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_utils.py +171 -0
- sqlspec/extensions/flask/extension.py +1234 -0
- sqlspec/extensions/litestar/__init__.py +52 -0
- sqlspec/extensions/litestar/_tenant_resolution.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_tenant_resolution.py +314 -0
- sqlspec/extensions/litestar/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_utils.py +222 -0
- sqlspec/extensions/litestar/channels.py +249 -0
- sqlspec/extensions/litestar/cli.py +100 -0
- sqlspec/extensions/litestar/config.py +5 -0
- sqlspec/extensions/litestar/handlers.py +796 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +138 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/migrations/reconcile.py +132 -0
- sqlspec/extensions/litestar/plugin.py +2172 -0
- sqlspec/extensions/litestar/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/providers.py +1239 -0
- sqlspec/extensions/litestar/store.py +613 -0
- sqlspec/extensions/litestar/tenant.py +292 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +5 -0
- sqlspec/extensions/prometheus/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/prometheus/_observer.py +152 -0
- sqlspec/extensions/sanic/__init__.py +28 -0
- sqlspec/extensions/sanic/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_state.py +102 -0
- sqlspec/extensions/sanic/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_utils.py +234 -0
- sqlspec/extensions/sanic/extension.py +1467 -0
- sqlspec/extensions/starlette/__init__.py +31 -0
- sqlspec/extensions/starlette/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_state.py +103 -0
- sqlspec/extensions/starlette/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_utils.py +267 -0
- sqlspec/extensions/starlette/extension.py +691 -0
- sqlspec/extensions/starlette/middleware.py +845 -0
- sqlspec/loader.cp315-win_amd64.pyd +0 -0
- sqlspec/loader.py +1733 -0
- sqlspec/migrations/__init__.py +104 -0
- sqlspec/migrations/_backup.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/_backup.py +36 -0
- sqlspec/migrations/base.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/base.py +1688 -0
- sqlspec/migrations/commands.py +4002 -0
- sqlspec/migrations/context.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/context.py +158 -0
- sqlspec/migrations/fix.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/fix.py +193 -0
- sqlspec/migrations/loaders.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/loaders.py +835 -0
- sqlspec/migrations/runner.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/runner.py +2144 -0
- sqlspec/migrations/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/schema.py +1266 -0
- sqlspec/migrations/squash.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/squash.py +2452 -0
- sqlspec/migrations/templates.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/templates.py +310 -0
- sqlspec/migrations/tracker.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/tracker.py +1529 -0
- sqlspec/migrations/utils.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/utils.py +534 -0
- sqlspec/migrations/validation.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/validation.py +355 -0
- sqlspec/migrations/version.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/version.py +455 -0
- sqlspec/observability/__init__.py +122 -0
- sqlspec/observability/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_common.py +307 -0
- sqlspec/observability/_config.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_config.py +362 -0
- sqlspec/observability/_diagnostics.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_diagnostics.py +75 -0
- sqlspec/observability/_dispatcher.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_dispatcher.py +320 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_aws.py +90 -0
- sqlspec/observability/_formatters/_azure.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_azure.py +84 -0
- sqlspec/observability/_formatters/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_base.py +40 -0
- sqlspec/observability/_formatters/_gcp.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_gcp.py +119 -0
- sqlspec/observability/_formatting.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatting.py +76 -0
- sqlspec/observability/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_observer.py +445 -0
- sqlspec/observability/_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_runtime.py +740 -0
- sqlspec/observability/_sampling.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_sampling.py +169 -0
- sqlspec/observability/_spans.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_spans.py +212 -0
- sqlspec/protocols.py +1235 -0
- sqlspec/py.typed +0 -0
- sqlspec/service/__init__.py +5 -0
- sqlspec/service/_base.py +1051 -0
- sqlspec/service/_core.cp315-win_amd64.pyd +0 -0
- sqlspec/service/_core.py +625 -0
- sqlspec/storage/__init__.py +111 -0
- sqlspec/storage/_arrow_payload.py +802 -0
- sqlspec/storage/_arrow_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_arrow_stream.py +134 -0
- sqlspec/storage/_ingest.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_ingest.py +810 -0
- sqlspec/storage/_paths.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_paths.py +313 -0
- sqlspec/storage/_staging_sql.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_staging_sql.py +695 -0
- sqlspec/storage/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_utils.py +174 -0
- sqlspec/storage/backends/__init__.py +43 -0
- sqlspec/storage/backends/base.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/base.py +399 -0
- sqlspec/storage/backends/fsspec.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/fsspec.py +1390 -0
- sqlspec/storage/backends/local.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/local.py +968 -0
- sqlspec/storage/backends/obstore.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/obstore.py +1974 -0
- sqlspec/storage/errors.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/errors.py +127 -0
- sqlspec/storage/pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/pipeline.py +1270 -0
- sqlspec/storage/registry.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/registry.py +318 -0
- sqlspec/typing.py +261 -0
- sqlspec/utils/__init__.py +9 -0
- sqlspec/utils/adapters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/adapters.py +186 -0
- sqlspec/utils/arrow_helpers.py +2157 -0
- sqlspec/utils/config_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/config_tools.py +712 -0
- sqlspec/utils/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/correlation.py +137 -0
- sqlspec/utils/deprecation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/deprecation.py +222 -0
- sqlspec/utils/dispatch.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/dispatch.py +104 -0
- sqlspec/utils/env.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/env.py +437 -0
- sqlspec/utils/fixtures.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/fixtures.py +2470 -0
- sqlspec/utils/logging.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/logging.py +267 -0
- sqlspec/utils/module_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/module_loader.py +399 -0
- sqlspec/utils/portal.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/portal.py +411 -0
- sqlspec/utils/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/routing.py +645 -0
- sqlspec/utils/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/schema.py +1050 -0
- sqlspec/utils/serializers/__init__.py +69 -0
- sqlspec/utils/serializers/_json.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_json.py +525 -0
- sqlspec/utils/serializers/_numpy.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_numpy.py +65 -0
- sqlspec/utils/serializers/_schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_schema.py +340 -0
- sqlspec/utils/sync_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/sync_tools.py +502 -0
- sqlspec/utils/tenant/__init__.py +71 -0
- sqlspec/utils/tenant/_context.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_context.py +550 -0
- sqlspec/utils/tenant/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_cursor.py +43 -0
- sqlspec/utils/tenant/_mssql.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_mssql.py +189 -0
- sqlspec/utils/tenant/_postgres.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_postgres.py +142 -0
- sqlspec/utils/text.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/text.py +317 -0
- sqlspec/utils/type_converters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_converters.py +220 -0
- sqlspec/utils/type_guards.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_guards.py +1505 -0
- sqlspec/utils/uuids.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/uuids.py +263 -0
- sqlspec-0.72.0.dist-info/METADATA +228 -0
- sqlspec-0.72.0.dist-info/RECORD +1144 -0
- sqlspec-0.72.0.dist-info/WHEEL +4 -0
- sqlspec-0.72.0.dist-info/entry_points.txt +13 -0
- sqlspec-0.72.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1529 @@
|
|
|
1
|
+
"""Migration version tracking for SQLSpec.
|
|
2
|
+
|
|
3
|
+
This module provides functionality to track applied migrations in the database.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import importlib
|
|
7
|
+
import logging
|
|
8
|
+
from asyncio import sleep as _async_sleep
|
|
9
|
+
from collections.abc import Sequence
|
|
10
|
+
from contextlib import suppress
|
|
11
|
+
from time import monotonic as _monotonic
|
|
12
|
+
from time import sleep as _sleep
|
|
13
|
+
from time import time as _time
|
|
14
|
+
from typing import TYPE_CHECKING, Any, Final, Literal, cast
|
|
15
|
+
|
|
16
|
+
from mypy_extensions import mypyc_attr
|
|
17
|
+
|
|
18
|
+
from sqlspec.exceptions import IntegrityError, MigrationError, SerializationConflictError, SQLSpecError, with_cause
|
|
19
|
+
from sqlspec.migrations.base import (
|
|
20
|
+
_PG_RELATION_GUARD_SQL,
|
|
21
|
+
BaseMigrationTracker,
|
|
22
|
+
_extract_catalog_rows,
|
|
23
|
+
_supports_postgres_row_security,
|
|
24
|
+
)
|
|
25
|
+
from sqlspec.migrations.runner import _driver_in_transaction_async, _driver_in_transaction_sync
|
|
26
|
+
from sqlspec.migrations.schema import ensure_schema_async, ensure_schema_sync
|
|
27
|
+
from sqlspec.observability._common import resolve_db_system
|
|
28
|
+
from sqlspec.utils.logging import get_logger, log_with_context
|
|
29
|
+
from sqlspec.utils.uuids import uuid4
|
|
30
|
+
|
|
31
|
+
if TYPE_CHECKING:
|
|
32
|
+
from collections.abc import Mapping
|
|
33
|
+
from types import TracebackType
|
|
34
|
+
|
|
35
|
+
from rich.console import Console
|
|
36
|
+
|
|
37
|
+
from sqlspec.driver._async import AsyncDriverAdapterBase
|
|
38
|
+
from sqlspec.driver._sync import SyncDriverAdapterBase
|
|
39
|
+
from sqlspec.migrations.base import AppliedMigrationRecord
|
|
40
|
+
|
|
41
|
+
__all__ = ("AsyncMigrationTracker", "SyncMigrationTracker")
|
|
42
|
+
|
|
43
|
+
logger = get_logger("sqlspec.migrations.tracker")
|
|
44
|
+
_console: "Console | None" = None
|
|
45
|
+
_MILLISECONDS_PER_SECOND: Final[int] = 1000
|
|
46
|
+
_POSTGRES_LOCK_POLL_INTERVAL_SECONDS: Final[float] = 0.05
|
|
47
|
+
_LEASE_LOCK_POLL_INTERVAL_SECONDS: Final[float] = 0.25
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
51
|
+
class SyncMigrationTracker(BaseMigrationTracker["SyncDriverAdapterBase"]):
|
|
52
|
+
"""Synchronous migration version tracker."""
|
|
53
|
+
|
|
54
|
+
def ensure_tracking_table(self, driver: "SyncDriverAdapterBase") -> None:
|
|
55
|
+
"""Create the migration tracking table if it doesn't exist.
|
|
56
|
+
|
|
57
|
+
Also checks for and adds any missing columns to support schema migrations.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
driver: The database driver to use.
|
|
61
|
+
"""
|
|
62
|
+
self._recheck_tracking_relation_sync(driver)
|
|
63
|
+
|
|
64
|
+
driver.execute(self._tracking_table_ddl())
|
|
65
|
+
self._safe_commit(driver)
|
|
66
|
+
|
|
67
|
+
self._migrate_schema_if_needed(driver)
|
|
68
|
+
|
|
69
|
+
def _recheck_tracking_relation_sync(self, driver: "SyncDriverAdapterBase") -> None:
|
|
70
|
+
"""Pin the tracking schema and validate the PostgreSQL tracking relation.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
driver: The database driver to use.
|
|
74
|
+
|
|
75
|
+
Raises:
|
|
76
|
+
MigrationError: If the schema cannot be resolved or the relation is unsafe.
|
|
77
|
+
"""
|
|
78
|
+
if not _supports_postgres_row_security(driver):
|
|
79
|
+
return
|
|
80
|
+
self._reset_version_table_schema()
|
|
81
|
+
if self.version_table_schema is None:
|
|
82
|
+
schema_result = driver.execute("SELECT current_schema() AS schema_name")
|
|
83
|
+
self._pin_version_table_schema(_resolve_current_schema(schema_result))
|
|
84
|
+
relation_result = driver.execute(_PG_RELATION_GUARD_SQL, self._pg_relation_guard_parameters())
|
|
85
|
+
_validate_pg_relation_rows(_extract_catalog_rows(relation_result), self.version_table)
|
|
86
|
+
|
|
87
|
+
def get_current_version(self, driver: "SyncDriverAdapterBase") -> str | None:
|
|
88
|
+
"""Get the latest applied migration version.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
driver: The database driver to use.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
The current version number or None if no migrations applied.
|
|
95
|
+
"""
|
|
96
|
+
result = driver.execute(self._current_version_query())
|
|
97
|
+
return _finalize_current_version(driver, result)
|
|
98
|
+
|
|
99
|
+
def get_applied_migrations(self, driver: "SyncDriverAdapterBase") -> "list[AppliedMigrationRecord]":
|
|
100
|
+
"""Get all applied migrations in order.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
driver: The database driver to use.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
List of migration records.
|
|
107
|
+
"""
|
|
108
|
+
result = driver.execute(self._applied_migrations_query())
|
|
109
|
+
return _finalize_applied_migrations(driver, result)
|
|
110
|
+
|
|
111
|
+
def record_migration(
|
|
112
|
+
self,
|
|
113
|
+
driver: "SyncDriverAdapterBase",
|
|
114
|
+
version: str,
|
|
115
|
+
description: str,
|
|
116
|
+
execution_time_ms: int,
|
|
117
|
+
checksum: str,
|
|
118
|
+
*,
|
|
119
|
+
commit: bool = True,
|
|
120
|
+
replaces: "Sequence[str] | None" = None,
|
|
121
|
+
) -> None:
|
|
122
|
+
"""Record a successfully applied migration.
|
|
123
|
+
|
|
124
|
+
Parses version to determine type (sequential or timestamp) and
|
|
125
|
+
auto-increments execution_sequence for application order tracking.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
driver: The database driver to use.
|
|
129
|
+
version: Version number of the migration.
|
|
130
|
+
description: Description of the migration.
|
|
131
|
+
execution_time_ms: Execution time in milliseconds.
|
|
132
|
+
checksum: SHA-256 checksum hex string of the migration content.
|
|
133
|
+
commit: Whether to commit immediately after recording.
|
|
134
|
+
replaces: Optional sequence of replaced migration versions for squashed migrations.
|
|
135
|
+
"""
|
|
136
|
+
version_type = self._derive_version_type(version)
|
|
137
|
+
replaces_csv = ",".join(replaces) if replaces else None
|
|
138
|
+
if self._uses_sequenced_insert(driver):
|
|
139
|
+
statement: Any = self._record_sequenced_migration_statement(
|
|
140
|
+
version, version_type, description, execution_time_ms, checksum, self._applied_by(), replaces_csv
|
|
141
|
+
)
|
|
142
|
+
else:
|
|
143
|
+
seq_result = driver.execute(self._next_execution_sequence_query())
|
|
144
|
+
next_sequence = self._extract_next_sequence(seq_result)
|
|
145
|
+
|
|
146
|
+
statement = self._record_statement(
|
|
147
|
+
version,
|
|
148
|
+
version_type,
|
|
149
|
+
next_sequence,
|
|
150
|
+
description,
|
|
151
|
+
execution_time_ms,
|
|
152
|
+
checksum,
|
|
153
|
+
self._applied_by(),
|
|
154
|
+
replaces,
|
|
155
|
+
)
|
|
156
|
+
driver.execute(statement)
|
|
157
|
+
if commit:
|
|
158
|
+
self._safe_commit(driver)
|
|
159
|
+
_log_migration_recorded(driver, version)
|
|
160
|
+
|
|
161
|
+
def remove_migration(self, driver: "SyncDriverAdapterBase", version: str, *, commit: bool = True) -> None:
|
|
162
|
+
"""Remove a migration record (used during downgrade).
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
driver: The database driver to use.
|
|
166
|
+
version: Version number to remove.
|
|
167
|
+
commit: Whether to commit immediately after removing.
|
|
168
|
+
"""
|
|
169
|
+
driver.execute(self._remove_migration_statement(version))
|
|
170
|
+
if commit:
|
|
171
|
+
self._safe_commit(driver)
|
|
172
|
+
_log_migration_removed(driver, version)
|
|
173
|
+
|
|
174
|
+
def update_version_record(
|
|
175
|
+
self,
|
|
176
|
+
driver: "SyncDriverAdapterBase",
|
|
177
|
+
old_version: str,
|
|
178
|
+
new_version: str,
|
|
179
|
+
applied_versions: "set[str] | None" = None,
|
|
180
|
+
) -> None:
|
|
181
|
+
"""Update migration version record from timestamp to sequential.
|
|
182
|
+
|
|
183
|
+
Updates version_num and version_type while preserving execution_sequence,
|
|
184
|
+
applied_at, and other tracking metadata. Used during fix command.
|
|
185
|
+
|
|
186
|
+
Idempotent: If the version is already updated, logs and continues without error.
|
|
187
|
+
This allows fix command to be safely re-run after pulling changes.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
driver: The database driver to use.
|
|
191
|
+
old_version: Current timestamp version string.
|
|
192
|
+
new_version: New sequential version string.
|
|
193
|
+
applied_versions: Previously loaded version set for batch reuse.
|
|
194
|
+
|
|
195
|
+
Raises:
|
|
196
|
+
ValueError: If neither old_version nor new_version found in database.
|
|
197
|
+
"""
|
|
198
|
+
new_version_type = self._derive_version_type(new_version)
|
|
199
|
+
|
|
200
|
+
result = driver.execute(self._update_version_statement(old_version, new_version, new_version_type))
|
|
201
|
+
|
|
202
|
+
if result.rows_affected == 0:
|
|
203
|
+
if applied_versions is None:
|
|
204
|
+
check_result = driver.execute(self._applied_migrations_query())
|
|
205
|
+
applied_versions = self._extract_applied_versions(check_result)
|
|
206
|
+
if _resolve_version_update_miss(driver, old_version, new_version, applied_versions):
|
|
207
|
+
return
|
|
208
|
+
|
|
209
|
+
self._safe_commit(driver)
|
|
210
|
+
_log_version_updated(driver, old_version, new_version)
|
|
211
|
+
|
|
212
|
+
def update_checksum(self, driver: "SyncDriverAdapterBase", version: str, checksum: str) -> None:
|
|
213
|
+
"""Replace the recorded checksum of an applied migration.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
driver: The database driver to use.
|
|
217
|
+
version: Version whose checksum is replaced.
|
|
218
|
+
checksum: New checksum hex string.
|
|
219
|
+
"""
|
|
220
|
+
driver.execute(self._update_checksum_statement(version, checksum))
|
|
221
|
+
self._safe_commit(driver)
|
|
222
|
+
|
|
223
|
+
def replace_with_squash(
|
|
224
|
+
self,
|
|
225
|
+
driver: "SyncDriverAdapterBase",
|
|
226
|
+
squashed_version: str,
|
|
227
|
+
replaced_versions: "list[str]",
|
|
228
|
+
description: str,
|
|
229
|
+
checksum: str,
|
|
230
|
+
) -> None:
|
|
231
|
+
"""Replace multiple migration records with a single squashed record.
|
|
232
|
+
|
|
233
|
+
Deletes all replaced version records and inserts a new record for the
|
|
234
|
+
squashed migration with metadata about which versions it replaces.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
driver: The database driver to use.
|
|
238
|
+
squashed_version: Version number of the squashed migration.
|
|
239
|
+
replaced_versions: List of version strings being replaced.
|
|
240
|
+
description: Description of the squashed migration.
|
|
241
|
+
checksum: SHA-256 checksum hex string of the squashed migration content.
|
|
242
|
+
"""
|
|
243
|
+
driver.execute(self._delete_versions_statement(replaced_versions))
|
|
244
|
+
|
|
245
|
+
version_type = self._derive_version_type(squashed_version)
|
|
246
|
+
replaces_csv = ",".join(replaced_versions) if replaced_versions else None
|
|
247
|
+
if self._uses_sequenced_insert(driver):
|
|
248
|
+
statement: Any = self._record_sequenced_migration_statement(
|
|
249
|
+
squashed_version, version_type, description, 0, checksum, self._applied_by(), replaces_csv
|
|
250
|
+
)
|
|
251
|
+
else:
|
|
252
|
+
seq_result = driver.execute(self._next_execution_sequence_query())
|
|
253
|
+
next_sequence = self._extract_next_sequence(seq_result)
|
|
254
|
+
statement = self._record_statement(
|
|
255
|
+
squashed_version,
|
|
256
|
+
version_type,
|
|
257
|
+
next_sequence,
|
|
258
|
+
description,
|
|
259
|
+
0,
|
|
260
|
+
checksum,
|
|
261
|
+
self._applied_by(),
|
|
262
|
+
replaced_versions,
|
|
263
|
+
)
|
|
264
|
+
driver.execute(statement)
|
|
265
|
+
|
|
266
|
+
self._safe_commit(driver)
|
|
267
|
+
_log_squash_recorded(driver, squashed_version, len(replaced_versions))
|
|
268
|
+
|
|
269
|
+
def is_squash_already_applied(
|
|
270
|
+
self, driver: "SyncDriverAdapterBase", squashed_version: str, replaced_versions: "list[str]"
|
|
271
|
+
) -> bool:
|
|
272
|
+
"""Check if a squash operation has already been applied.
|
|
273
|
+
|
|
274
|
+
Determines if all of the replaced versions exist in the database,
|
|
275
|
+
indicating that the original migrations were applied before the squash.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
driver: The database driver to use.
|
|
279
|
+
squashed_version: Version number of the squashed migration.
|
|
280
|
+
replaced_versions: List of version strings that would be replaced.
|
|
281
|
+
|
|
282
|
+
Returns:
|
|
283
|
+
True if all replaced versions exist (squash already applied), False if none exist.
|
|
284
|
+
|
|
285
|
+
Raises:
|
|
286
|
+
MigrationError: If only a strict subset of replaced_versions exists in the database.
|
|
287
|
+
"""
|
|
288
|
+
result = driver.execute(self._check_versions_query(replaced_versions))
|
|
289
|
+
return _validate_squash_applied_state(result, squashed_version, replaced_versions)
|
|
290
|
+
|
|
291
|
+
def renew_lock(self, driver: "SyncDriverAdapterBase") -> None:
|
|
292
|
+
"""Extend the lease this tracker holds on ``driver``.
|
|
293
|
+
|
|
294
|
+
A no-op unless a lease lock is held.
|
|
295
|
+
|
|
296
|
+
Args:
|
|
297
|
+
driver: Active session driver.
|
|
298
|
+
|
|
299
|
+
Raises:
|
|
300
|
+
MigrationError: If this tracker no longer holds the lease. A driver that reports no affected
|
|
301
|
+
rows is checked against the stored lease row.
|
|
302
|
+
"""
|
|
303
|
+
held = self._lease_owners.get(id(driver))
|
|
304
|
+
if held is None:
|
|
305
|
+
return
|
|
306
|
+
expires_at = _wall_clock_ms() + self.lock_lease_seconds * _MILLISECONDS_PER_SECOND
|
|
307
|
+
result = driver.execute(self._lease_renew(held[0], held[1], expires_at))
|
|
308
|
+
if getattr(result, "rows_affected", None) == 0:
|
|
309
|
+
holder = self._lease_holder(driver.execute(self._lease_owner_query(held[0])))
|
|
310
|
+
if holder != (held[1], expires_at):
|
|
311
|
+
raise _lease_expired_error()
|
|
312
|
+
self._safe_commit(driver)
|
|
313
|
+
|
|
314
|
+
def acquire_lock(
|
|
315
|
+
self, driver: "SyncDriverAdapterBase", *, timeout_seconds: int = 30
|
|
316
|
+
) -> "_SyncMigrationLockContext":
|
|
317
|
+
"""Serialize mutating migration sessions using a dialect-appropriate lock.
|
|
318
|
+
|
|
319
|
+
PostgreSQL uses session advisory locks (skipped for CockroachDB drivers), MySQL and
|
|
320
|
+
MariaDB use ``GET_LOCK`` / ``RELEASE_LOCK``, SQL Server uses ``sp_getapplock`` /
|
|
321
|
+
``sp_releaseapplock``, and SQLite takes an immediate transaction lock when no
|
|
322
|
+
transaction is already open. CockroachDB, Oracle, DuckDB, Spanner, Db2, Sybase, SQL Anywhere,
|
|
323
|
+
Teradata, and bridge-driver SQLite take a lease row in ``<version_table>_lock``. BigQuery and
|
|
324
|
+
Snowflake log a warning and proceed unserialized.
|
|
325
|
+
|
|
326
|
+
Args:
|
|
327
|
+
driver: Active session driver.
|
|
328
|
+
timeout_seconds: Lock acquisition timeout for timed lock backends.
|
|
329
|
+
|
|
330
|
+
Returns:
|
|
331
|
+
Synchronous context manager holding the migration lock while entered.
|
|
332
|
+
"""
|
|
333
|
+
return _SyncMigrationLockContext(self, driver, timeout_seconds=timeout_seconds)
|
|
334
|
+
|
|
335
|
+
def _migrate_schema_if_needed(self, driver: "SyncDriverAdapterBase") -> None:
|
|
336
|
+
"""Add missing tracking-table columns through the shared schema engine.
|
|
337
|
+
|
|
338
|
+
Args:
|
|
339
|
+
driver: The database driver to use.
|
|
340
|
+
"""
|
|
341
|
+
locked = self.holds_transaction_scoped_lock(driver)
|
|
342
|
+
savepoint = "sqlspec_tracker_schema"
|
|
343
|
+
schema_error: BaseException | None = None
|
|
344
|
+
if locked:
|
|
345
|
+
driver.create_savepoint(savepoint)
|
|
346
|
+
try:
|
|
347
|
+
target = self._tracking_schema_target()
|
|
348
|
+
result = ensure_schema_sync(
|
|
349
|
+
driver, [target], manage_schema=True, create_schema=False, assume_existing=True, commit=not locked
|
|
350
|
+
)
|
|
351
|
+
added_columns = result.added_columns.get(target.identity, [])
|
|
352
|
+
if not added_columns:
|
|
353
|
+
if locked:
|
|
354
|
+
driver.release_savepoint(savepoint)
|
|
355
|
+
_log_schema_current(driver, self.version_table)
|
|
356
|
+
return
|
|
357
|
+
if self._should_echo():
|
|
358
|
+
_get_console().print(
|
|
359
|
+
f"[cyan]Migrating tracking table schema, adding columns: {', '.join(added_columns)}[/]"
|
|
360
|
+
)
|
|
361
|
+
for column_name in added_columns:
|
|
362
|
+
_log_column_added(driver, self.version_table, column_name)
|
|
363
|
+
if self._should_echo():
|
|
364
|
+
_get_console().print("[green]Migration tracking table schema updated successfully[/]")
|
|
365
|
+
if locked:
|
|
366
|
+
driver.release_savepoint(savepoint)
|
|
367
|
+
except BaseException as exc:
|
|
368
|
+
schema_error = exc
|
|
369
|
+
if schema_error is not None:
|
|
370
|
+
if locked:
|
|
371
|
+
with suppress(Exception):
|
|
372
|
+
driver.rollback_to_savepoint(savepoint)
|
|
373
|
+
with suppress(Exception):
|
|
374
|
+
driver.release_savepoint(savepoint)
|
|
375
|
+
else:
|
|
376
|
+
with suppress(Exception):
|
|
377
|
+
driver.rollback()
|
|
378
|
+
if not isinstance(schema_error, Exception):
|
|
379
|
+
raise schema_error
|
|
380
|
+
_log_schema_check_failed(driver, self.version_table, schema_error)
|
|
381
|
+
|
|
382
|
+
def _safe_commit(self, driver: "SyncDriverAdapterBase") -> None:
|
|
383
|
+
"""Safely commit a transaction only if autocommit is disabled.
|
|
384
|
+
|
|
385
|
+
Args:
|
|
386
|
+
driver: The database driver to use.
|
|
387
|
+
"""
|
|
388
|
+
if self.holds_transaction_scoped_lock(driver) or driver.driver_features.get("autocommit", False):
|
|
389
|
+
return
|
|
390
|
+
|
|
391
|
+
try:
|
|
392
|
+
driver.commit()
|
|
393
|
+
except Exception as exc:
|
|
394
|
+
if self._is_autocommit_error(exc):
|
|
395
|
+
_log_commit_skipped(driver, exc)
|
|
396
|
+
else:
|
|
397
|
+
raise
|
|
398
|
+
|
|
399
|
+
def _record_statement(
|
|
400
|
+
self,
|
|
401
|
+
version: str,
|
|
402
|
+
version_type: str,
|
|
403
|
+
execution_sequence: int,
|
|
404
|
+
description: str,
|
|
405
|
+
execution_time_ms: int,
|
|
406
|
+
checksum: str,
|
|
407
|
+
applied_by: str,
|
|
408
|
+
replaces: "Sequence[str] | None" = None,
|
|
409
|
+
) -> Any:
|
|
410
|
+
"""Build an INSERT statement for a standard or squashed migration record."""
|
|
411
|
+
return _build_record_statement(
|
|
412
|
+
self,
|
|
413
|
+
version,
|
|
414
|
+
version_type,
|
|
415
|
+
execution_sequence,
|
|
416
|
+
description,
|
|
417
|
+
execution_time_ms,
|
|
418
|
+
checksum,
|
|
419
|
+
applied_by,
|
|
420
|
+
replaces,
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
425
|
+
class AsyncMigrationTracker(BaseMigrationTracker["AsyncDriverAdapterBase"]):
|
|
426
|
+
"""Asynchronous migration version tracker."""
|
|
427
|
+
|
|
428
|
+
async def ensure_tracking_table(self, driver: "AsyncDriverAdapterBase") -> None:
|
|
429
|
+
"""Create the migration tracking table if it doesn't exist.
|
|
430
|
+
|
|
431
|
+
Also checks for and adds any missing columns to support schema migrations.
|
|
432
|
+
|
|
433
|
+
Args:
|
|
434
|
+
driver: The database driver to use.
|
|
435
|
+
"""
|
|
436
|
+
await self._recheck_tracking_relation_async(driver)
|
|
437
|
+
|
|
438
|
+
await driver.execute(self._tracking_table_ddl())
|
|
439
|
+
await self._safe_commit(driver)
|
|
440
|
+
|
|
441
|
+
await self._migrate_schema_if_needed(driver)
|
|
442
|
+
|
|
443
|
+
async def _recheck_tracking_relation_async(self, driver: "AsyncDriverAdapterBase") -> None:
|
|
444
|
+
"""Pin the tracking schema and validate the PostgreSQL tracking relation.
|
|
445
|
+
|
|
446
|
+
Args:
|
|
447
|
+
driver: The database driver to use.
|
|
448
|
+
|
|
449
|
+
Raises:
|
|
450
|
+
MigrationError: If the schema cannot be resolved or the relation is unsafe.
|
|
451
|
+
"""
|
|
452
|
+
if not _supports_postgres_row_security(driver):
|
|
453
|
+
return
|
|
454
|
+
self._reset_version_table_schema()
|
|
455
|
+
if self.version_table_schema is None:
|
|
456
|
+
schema_result = await driver.execute("SELECT current_schema() AS schema_name")
|
|
457
|
+
self._pin_version_table_schema(_resolve_current_schema(schema_result))
|
|
458
|
+
relation_result = await driver.execute(_PG_RELATION_GUARD_SQL, self._pg_relation_guard_parameters())
|
|
459
|
+
_validate_pg_relation_rows(_extract_catalog_rows(relation_result), self.version_table)
|
|
460
|
+
|
|
461
|
+
async def get_current_version(self, driver: "AsyncDriverAdapterBase") -> str | None:
|
|
462
|
+
"""Get the latest applied migration version.
|
|
463
|
+
|
|
464
|
+
Args:
|
|
465
|
+
driver: The database driver to use.
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
The current version number or None if no migrations applied.
|
|
469
|
+
"""
|
|
470
|
+
result = await driver.execute(self._current_version_query())
|
|
471
|
+
return _finalize_current_version(driver, result)
|
|
472
|
+
|
|
473
|
+
async def get_applied_migrations(self, driver: "AsyncDriverAdapterBase") -> "list[AppliedMigrationRecord]":
|
|
474
|
+
"""Get all applied migrations in order.
|
|
475
|
+
|
|
476
|
+
Args:
|
|
477
|
+
driver: The database driver to use.
|
|
478
|
+
|
|
479
|
+
Returns:
|
|
480
|
+
List of migration records.
|
|
481
|
+
"""
|
|
482
|
+
result = await driver.execute(self._applied_migrations_query())
|
|
483
|
+
return _finalize_applied_migrations(driver, result)
|
|
484
|
+
|
|
485
|
+
async def record_migration(
|
|
486
|
+
self,
|
|
487
|
+
driver: "AsyncDriverAdapterBase",
|
|
488
|
+
version: str,
|
|
489
|
+
description: str,
|
|
490
|
+
execution_time_ms: int,
|
|
491
|
+
checksum: str,
|
|
492
|
+
*,
|
|
493
|
+
commit: bool = True,
|
|
494
|
+
replaces: "Sequence[str] | None" = None,
|
|
495
|
+
) -> None:
|
|
496
|
+
"""Record a successfully applied migration.
|
|
497
|
+
|
|
498
|
+
Parses version to determine type (sequential or timestamp) and
|
|
499
|
+
auto-increments execution_sequence for application order tracking.
|
|
500
|
+
|
|
501
|
+
Args:
|
|
502
|
+
driver: The database driver to use.
|
|
503
|
+
version: Version number of the migration.
|
|
504
|
+
description: Description of the migration.
|
|
505
|
+
execution_time_ms: Execution time in milliseconds.
|
|
506
|
+
checksum: SHA-256 checksum hex string of the migration content.
|
|
507
|
+
commit: Whether to commit immediately after recording.
|
|
508
|
+
replaces: Optional sequence of replaced migration versions for squashed migrations.
|
|
509
|
+
"""
|
|
510
|
+
version_type = self._derive_version_type(version)
|
|
511
|
+
replaces_csv = ",".join(replaces) if replaces else None
|
|
512
|
+
if self._uses_sequenced_insert(driver):
|
|
513
|
+
statement: Any = self._record_sequenced_migration_statement(
|
|
514
|
+
version, version_type, description, execution_time_ms, checksum, self._applied_by(), replaces_csv
|
|
515
|
+
)
|
|
516
|
+
else:
|
|
517
|
+
seq_result = await driver.execute(self._next_execution_sequence_query())
|
|
518
|
+
next_sequence = self._extract_next_sequence(seq_result)
|
|
519
|
+
|
|
520
|
+
statement = self._record_statement(
|
|
521
|
+
version,
|
|
522
|
+
version_type,
|
|
523
|
+
next_sequence,
|
|
524
|
+
description,
|
|
525
|
+
execution_time_ms,
|
|
526
|
+
checksum,
|
|
527
|
+
self._applied_by(),
|
|
528
|
+
replaces,
|
|
529
|
+
)
|
|
530
|
+
await driver.execute(statement)
|
|
531
|
+
if commit:
|
|
532
|
+
await self._safe_commit(driver)
|
|
533
|
+
_log_migration_recorded(driver, version)
|
|
534
|
+
|
|
535
|
+
async def remove_migration(self, driver: "AsyncDriverAdapterBase", version: str, *, commit: bool = True) -> None:
|
|
536
|
+
"""Remove a migration record (used during downgrade).
|
|
537
|
+
|
|
538
|
+
Args:
|
|
539
|
+
driver: The database driver to use.
|
|
540
|
+
version: Version number to remove.
|
|
541
|
+
commit: Whether to commit immediately after removing.
|
|
542
|
+
"""
|
|
543
|
+
await driver.execute(self._remove_migration_statement(version))
|
|
544
|
+
if commit:
|
|
545
|
+
await self._safe_commit(driver)
|
|
546
|
+
_log_migration_removed(driver, version)
|
|
547
|
+
|
|
548
|
+
async def update_version_record(
|
|
549
|
+
self,
|
|
550
|
+
driver: "AsyncDriverAdapterBase",
|
|
551
|
+
old_version: str,
|
|
552
|
+
new_version: str,
|
|
553
|
+
applied_versions: "set[str] | None" = None,
|
|
554
|
+
) -> None:
|
|
555
|
+
"""Update migration version record from timestamp to sequential.
|
|
556
|
+
|
|
557
|
+
Updates version_num and version_type while preserving execution_sequence,
|
|
558
|
+
applied_at, and other tracking metadata. Used during fix command.
|
|
559
|
+
|
|
560
|
+
Idempotent: If the version is already updated, logs and continues without error.
|
|
561
|
+
This allows fix command to be safely re-run after pulling changes.
|
|
562
|
+
|
|
563
|
+
Args:
|
|
564
|
+
driver: The database driver to use.
|
|
565
|
+
old_version: Current timestamp version string.
|
|
566
|
+
new_version: New sequential version string.
|
|
567
|
+
applied_versions: Previously loaded version set for batch reuse.
|
|
568
|
+
|
|
569
|
+
Raises:
|
|
570
|
+
ValueError: If neither old_version nor new_version found in database.
|
|
571
|
+
"""
|
|
572
|
+
new_version_type = self._derive_version_type(new_version)
|
|
573
|
+
|
|
574
|
+
result = await driver.execute(self._update_version_statement(old_version, new_version, new_version_type))
|
|
575
|
+
|
|
576
|
+
if result.rows_affected == 0:
|
|
577
|
+
if applied_versions is None:
|
|
578
|
+
check_result = await driver.execute(self._applied_migrations_query())
|
|
579
|
+
applied_versions = self._extract_applied_versions(check_result)
|
|
580
|
+
if _resolve_version_update_miss(driver, old_version, new_version, applied_versions):
|
|
581
|
+
return
|
|
582
|
+
|
|
583
|
+
await self._safe_commit(driver)
|
|
584
|
+
_log_version_updated(driver, old_version, new_version)
|
|
585
|
+
|
|
586
|
+
async def update_checksum(self, driver: "AsyncDriverAdapterBase", version: str, checksum: str) -> None:
|
|
587
|
+
"""Replace the recorded checksum of an applied migration.
|
|
588
|
+
|
|
589
|
+
Args:
|
|
590
|
+
driver: The database driver to use.
|
|
591
|
+
version: Version whose checksum is replaced.
|
|
592
|
+
checksum: New checksum hex string.
|
|
593
|
+
"""
|
|
594
|
+
await driver.execute(self._update_checksum_statement(version, checksum))
|
|
595
|
+
await self._safe_commit(driver)
|
|
596
|
+
|
|
597
|
+
async def replace_with_squash(
|
|
598
|
+
self,
|
|
599
|
+
driver: "AsyncDriverAdapterBase",
|
|
600
|
+
squashed_version: str,
|
|
601
|
+
replaced_versions: "list[str]",
|
|
602
|
+
description: str,
|
|
603
|
+
checksum: str,
|
|
604
|
+
) -> None:
|
|
605
|
+
"""Replace multiple migration records with a single squashed record.
|
|
606
|
+
|
|
607
|
+
Deletes all replaced version records and inserts a new record for the
|
|
608
|
+
squashed migration with metadata about which versions it replaces.
|
|
609
|
+
|
|
610
|
+
Args:
|
|
611
|
+
driver: The database driver to use.
|
|
612
|
+
squashed_version: Version number of the squashed migration.
|
|
613
|
+
replaced_versions: List of version strings being replaced.
|
|
614
|
+
description: Description of the squashed migration.
|
|
615
|
+
checksum: SHA-256 checksum hex string of the squashed migration content.
|
|
616
|
+
"""
|
|
617
|
+
await driver.execute(self._delete_versions_statement(replaced_versions))
|
|
618
|
+
|
|
619
|
+
version_type = self._derive_version_type(squashed_version)
|
|
620
|
+
replaces_csv = ",".join(replaced_versions) if replaced_versions else None
|
|
621
|
+
if self._uses_sequenced_insert(driver):
|
|
622
|
+
statement: Any = self._record_sequenced_migration_statement(
|
|
623
|
+
squashed_version, version_type, description, 0, checksum, self._applied_by(), replaces_csv
|
|
624
|
+
)
|
|
625
|
+
else:
|
|
626
|
+
seq_result = await driver.execute(self._next_execution_sequence_query())
|
|
627
|
+
next_sequence = self._extract_next_sequence(seq_result)
|
|
628
|
+
statement = self._record_statement(
|
|
629
|
+
squashed_version,
|
|
630
|
+
version_type,
|
|
631
|
+
next_sequence,
|
|
632
|
+
description,
|
|
633
|
+
0,
|
|
634
|
+
checksum,
|
|
635
|
+
self._applied_by(),
|
|
636
|
+
replaced_versions,
|
|
637
|
+
)
|
|
638
|
+
await driver.execute(statement)
|
|
639
|
+
|
|
640
|
+
await self._safe_commit(driver)
|
|
641
|
+
_log_squash_recorded(driver, squashed_version, len(replaced_versions))
|
|
642
|
+
|
|
643
|
+
async def is_squash_already_applied(
|
|
644
|
+
self, driver: "AsyncDriverAdapterBase", squashed_version: str, replaced_versions: "list[str]"
|
|
645
|
+
) -> bool:
|
|
646
|
+
"""Check if a squash operation has already been applied.
|
|
647
|
+
|
|
648
|
+
Determines if all of the replaced versions exist in the database,
|
|
649
|
+
indicating that the original migrations were applied before the squash.
|
|
650
|
+
|
|
651
|
+
Args:
|
|
652
|
+
driver: The database driver to use.
|
|
653
|
+
squashed_version: Version number of the squashed migration.
|
|
654
|
+
replaced_versions: List of version strings that would be replaced.
|
|
655
|
+
|
|
656
|
+
Returns:
|
|
657
|
+
True if all replaced versions exist (squash already applied), False if none exist.
|
|
658
|
+
|
|
659
|
+
Raises:
|
|
660
|
+
MigrationError: If only a strict subset of replaced_versions exists in the database.
|
|
661
|
+
"""
|
|
662
|
+
result = await driver.execute(self._check_versions_query(replaced_versions))
|
|
663
|
+
return _validate_squash_applied_state(result, squashed_version, replaced_versions)
|
|
664
|
+
|
|
665
|
+
async def renew_lock(self, driver: "AsyncDriverAdapterBase") -> None:
|
|
666
|
+
"""Extend the lease this tracker holds on ``driver``.
|
|
667
|
+
|
|
668
|
+
A no-op unless a lease lock is held.
|
|
669
|
+
|
|
670
|
+
Args:
|
|
671
|
+
driver: Active async session driver.
|
|
672
|
+
|
|
673
|
+
Raises:
|
|
674
|
+
MigrationError: If this tracker no longer holds the lease. A driver that reports no affected
|
|
675
|
+
rows is checked against the stored lease row.
|
|
676
|
+
"""
|
|
677
|
+
held = self._lease_owners.get(id(driver))
|
|
678
|
+
if held is None:
|
|
679
|
+
return
|
|
680
|
+
expires_at = _wall_clock_ms() + self.lock_lease_seconds * _MILLISECONDS_PER_SECOND
|
|
681
|
+
result = await driver.execute(self._lease_renew(held[0], held[1], expires_at))
|
|
682
|
+
if getattr(result, "rows_affected", None) == 0:
|
|
683
|
+
holder = self._lease_holder(await driver.execute(self._lease_owner_query(held[0])))
|
|
684
|
+
if holder != (held[1], expires_at):
|
|
685
|
+
raise _lease_expired_error()
|
|
686
|
+
await self._safe_commit(driver)
|
|
687
|
+
|
|
688
|
+
def acquire_lock(
|
|
689
|
+
self, driver: "AsyncDriverAdapterBase", *, timeout_seconds: int = 30
|
|
690
|
+
) -> "_AsyncMigrationLockContext":
|
|
691
|
+
"""Serialize mutating migration sessions using a dialect-appropriate lock.
|
|
692
|
+
|
|
693
|
+
PostgreSQL uses session advisory locks (skipped for CockroachDB drivers), MySQL and
|
|
694
|
+
MariaDB use ``GET_LOCK`` / ``RELEASE_LOCK``, SQL Server uses ``sp_getapplock`` /
|
|
695
|
+
``sp_releaseapplock``, and SQLite takes an immediate transaction lock when no
|
|
696
|
+
transaction is already open. CockroachDB, Oracle, DuckDB, Spanner, Db2, Sybase, SQL Anywhere,
|
|
697
|
+
Teradata, and bridge-driver SQLite take a lease row in ``<version_table>_lock``. BigQuery and
|
|
698
|
+
Snowflake log a warning and proceed unserialized.
|
|
699
|
+
|
|
700
|
+
Args:
|
|
701
|
+
driver: Active async session driver.
|
|
702
|
+
timeout_seconds: Lock acquisition timeout for timed lock backends.
|
|
703
|
+
|
|
704
|
+
Returns:
|
|
705
|
+
Asynchronous context manager holding the migration lock while entered.
|
|
706
|
+
"""
|
|
707
|
+
return _AsyncMigrationLockContext(self, driver, timeout_seconds=timeout_seconds)
|
|
708
|
+
|
|
709
|
+
async def _migrate_schema_if_needed(self, driver: "AsyncDriverAdapterBase") -> None:
|
|
710
|
+
"""Add missing tracking-table columns through the shared schema engine.
|
|
711
|
+
|
|
712
|
+
Args:
|
|
713
|
+
driver: The database driver to use.
|
|
714
|
+
"""
|
|
715
|
+
locked = self.holds_transaction_scoped_lock(driver)
|
|
716
|
+
savepoint = "sqlspec_tracker_schema"
|
|
717
|
+
schema_error: BaseException | None = None
|
|
718
|
+
if locked:
|
|
719
|
+
await driver.create_savepoint(savepoint)
|
|
720
|
+
try:
|
|
721
|
+
target = self._tracking_schema_target()
|
|
722
|
+
result = await ensure_schema_async(
|
|
723
|
+
driver, [target], manage_schema=True, create_schema=False, assume_existing=True, commit=not locked
|
|
724
|
+
)
|
|
725
|
+
added_columns = result.added_columns.get(target.identity, [])
|
|
726
|
+
if not added_columns:
|
|
727
|
+
if locked:
|
|
728
|
+
await driver.release_savepoint(savepoint)
|
|
729
|
+
_log_schema_current(driver, self.version_table)
|
|
730
|
+
return
|
|
731
|
+
if self._should_echo():
|
|
732
|
+
_get_console().print(
|
|
733
|
+
f"[cyan]Migrating tracking table schema, adding columns: {', '.join(added_columns)}[/]"
|
|
734
|
+
)
|
|
735
|
+
for column_name in added_columns:
|
|
736
|
+
_log_column_added(driver, self.version_table, column_name)
|
|
737
|
+
if self._should_echo():
|
|
738
|
+
_get_console().print("[green]Migration tracking table schema updated successfully[/]")
|
|
739
|
+
if locked:
|
|
740
|
+
await driver.release_savepoint(savepoint)
|
|
741
|
+
except BaseException as exc:
|
|
742
|
+
schema_error = exc
|
|
743
|
+
if schema_error is not None:
|
|
744
|
+
if locked:
|
|
745
|
+
with suppress(Exception):
|
|
746
|
+
await driver.rollback_to_savepoint(savepoint)
|
|
747
|
+
with suppress(Exception):
|
|
748
|
+
await driver.release_savepoint(savepoint)
|
|
749
|
+
else:
|
|
750
|
+
with suppress(Exception):
|
|
751
|
+
await driver.rollback()
|
|
752
|
+
if not isinstance(schema_error, Exception):
|
|
753
|
+
raise schema_error
|
|
754
|
+
_log_schema_check_failed(driver, self.version_table, schema_error)
|
|
755
|
+
|
|
756
|
+
async def _safe_commit(self, driver: "AsyncDriverAdapterBase") -> None:
|
|
757
|
+
"""Safely commit a transaction only if autocommit is disabled.
|
|
758
|
+
|
|
759
|
+
Args:
|
|
760
|
+
driver: The database driver to use.
|
|
761
|
+
"""
|
|
762
|
+
if self.holds_transaction_scoped_lock(driver) or driver.driver_features.get("autocommit", False):
|
|
763
|
+
return
|
|
764
|
+
|
|
765
|
+
try:
|
|
766
|
+
await driver.commit()
|
|
767
|
+
except Exception as exc:
|
|
768
|
+
if self._is_autocommit_error(exc):
|
|
769
|
+
_log_commit_skipped(driver, exc)
|
|
770
|
+
else:
|
|
771
|
+
raise
|
|
772
|
+
|
|
773
|
+
def _record_statement(
|
|
774
|
+
self,
|
|
775
|
+
version: str,
|
|
776
|
+
version_type: str,
|
|
777
|
+
execution_sequence: int,
|
|
778
|
+
description: str,
|
|
779
|
+
execution_time_ms: int,
|
|
780
|
+
checksum: str,
|
|
781
|
+
applied_by: str,
|
|
782
|
+
replaces: "Sequence[str] | None" = None,
|
|
783
|
+
) -> Any:
|
|
784
|
+
"""Build an INSERT statement for a standard or squashed migration record."""
|
|
785
|
+
return _build_record_statement(
|
|
786
|
+
self,
|
|
787
|
+
version,
|
|
788
|
+
version_type,
|
|
789
|
+
execution_sequence,
|
|
790
|
+
description,
|
|
791
|
+
execution_time_ms,
|
|
792
|
+
checksum,
|
|
793
|
+
applied_by,
|
|
794
|
+
replaces,
|
|
795
|
+
)
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
def _build_record_statement(
|
|
799
|
+
tracker: BaseMigrationTracker[Any],
|
|
800
|
+
version: str,
|
|
801
|
+
version_type: str,
|
|
802
|
+
execution_sequence: int,
|
|
803
|
+
description: str,
|
|
804
|
+
execution_time_ms: int,
|
|
805
|
+
checksum: str,
|
|
806
|
+
applied_by: str,
|
|
807
|
+
replaces: "Sequence[str] | None" = None,
|
|
808
|
+
) -> Any:
|
|
809
|
+
"""Return an INSERT builder for either a standard or squashed migration record."""
|
|
810
|
+
if replaces:
|
|
811
|
+
return tracker._record_squashed_migration_statement(
|
|
812
|
+
version,
|
|
813
|
+
version_type,
|
|
814
|
+
execution_sequence,
|
|
815
|
+
description,
|
|
816
|
+
execution_time_ms,
|
|
817
|
+
checksum,
|
|
818
|
+
applied_by,
|
|
819
|
+
",".join(replaces),
|
|
820
|
+
)
|
|
821
|
+
return tracker._record_migration_statement(
|
|
822
|
+
version, version_type, execution_sequence, description, execution_time_ms, checksum, applied_by
|
|
823
|
+
)
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
with suppress(TypeError):
|
|
827
|
+
setattr(BaseMigrationTracker, "_record_statement", _build_record_statement)
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
def _validate_squash_applied_state(result: Any, squashed_version: str, replaced_versions: "list[str]") -> bool:
|
|
831
|
+
"""Validate that either all or none of the replaced versions are applied."""
|
|
832
|
+
if not result.data:
|
|
833
|
+
return False
|
|
834
|
+
data = result.get_data() if callable(getattr(result, "get_data", None)) else result.data
|
|
835
|
+
if isinstance(data, list) and data and isinstance(data[0], dict) and "version_num" in data[0]:
|
|
836
|
+
found_versions = {row["version_num"] for row in data if "version_num" in row}
|
|
837
|
+
expected_versions = set(replaced_versions)
|
|
838
|
+
if 0 < len(found_versions) < len(expected_versions):
|
|
839
|
+
missing = sorted(expected_versions - found_versions)
|
|
840
|
+
msg = (
|
|
841
|
+
f"Partial squash state detected for {squashed_version}: "
|
|
842
|
+
f"found {sorted(found_versions)}, missing {missing}"
|
|
843
|
+
)
|
|
844
|
+
raise MigrationError(msg)
|
|
845
|
+
return True
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
def _get_console() -> "Console":
|
|
849
|
+
global _console
|
|
850
|
+
if _console is None:
|
|
851
|
+
_console = cast("Console", importlib.import_module("rich.console").Console())
|
|
852
|
+
return _console
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
def _log_schema_current(driver: Any, version_table: str) -> None:
|
|
856
|
+
"""Log that the tracking table schema already has all columns."""
|
|
857
|
+
log_with_context(
|
|
858
|
+
logger,
|
|
859
|
+
logging.DEBUG,
|
|
860
|
+
"migration.track",
|
|
861
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
862
|
+
table=version_table,
|
|
863
|
+
operation="schema_check",
|
|
864
|
+
status="current",
|
|
865
|
+
)
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
def _log_schema_check_failed(driver: Any, version_table: str, exc: Exception) -> None:
|
|
869
|
+
"""Log that a tracking-table schema check failed."""
|
|
870
|
+
log_with_context(
|
|
871
|
+
logger,
|
|
872
|
+
logging.ERROR,
|
|
873
|
+
"migration.track",
|
|
874
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
875
|
+
table=version_table,
|
|
876
|
+
operation="schema_check",
|
|
877
|
+
status="failed",
|
|
878
|
+
error_type=type(exc).__name__,
|
|
879
|
+
)
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
def _log_column_added(driver: Any, version_table: str, column_name: str) -> None:
|
|
883
|
+
"""Log that a column was added to the tracking table."""
|
|
884
|
+
log_with_context(
|
|
885
|
+
logger,
|
|
886
|
+
logging.INFO,
|
|
887
|
+
"migration.track",
|
|
888
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
889
|
+
table=version_table,
|
|
890
|
+
column_name=column_name,
|
|
891
|
+
operation="schema_update",
|
|
892
|
+
status="column_added",
|
|
893
|
+
)
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
def _finalize_current_version(driver: Any, result: Any) -> "str | None":
|
|
897
|
+
"""Extract, log, and return the current migration version from a query result."""
|
|
898
|
+
current: str | None = None
|
|
899
|
+
if result.data:
|
|
900
|
+
first_row = result.get_data()[0]
|
|
901
|
+
raw_version = first_row.get("version_num") if "version_num" in first_row else first_row.get("VERSION_NUM")
|
|
902
|
+
current = str(raw_version) if raw_version is not None else None
|
|
903
|
+
log_with_context(
|
|
904
|
+
logger,
|
|
905
|
+
logging.DEBUG,
|
|
906
|
+
"migration.history",
|
|
907
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
908
|
+
current_version=current,
|
|
909
|
+
status="current",
|
|
910
|
+
)
|
|
911
|
+
return current
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
def _finalize_applied_migrations(driver: Any, result: Any) -> "list[AppliedMigrationRecord]":
|
|
915
|
+
"""Extract, log, and return applied migration records from a query result."""
|
|
916
|
+
rows = result.get_data()
|
|
917
|
+
if rows and isinstance(rows[0], dict) and "version_num" not in rows[0] and "VERSION_NUM" in rows[0]:
|
|
918
|
+
rows = [{str(key).lower(): value for key, value in row.items()} for row in rows]
|
|
919
|
+
applied = cast("list[AppliedMigrationRecord]", rows)
|
|
920
|
+
log_with_context(
|
|
921
|
+
logger,
|
|
922
|
+
logging.DEBUG,
|
|
923
|
+
"migration.history",
|
|
924
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
925
|
+
applied_count=len(applied),
|
|
926
|
+
status="listed",
|
|
927
|
+
)
|
|
928
|
+
return applied
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
def _log_migration_recorded(driver: Any, version: str) -> None:
|
|
932
|
+
"""Log that a migration was recorded."""
|
|
933
|
+
log_with_context(
|
|
934
|
+
logger,
|
|
935
|
+
logging.DEBUG,
|
|
936
|
+
"migration.track",
|
|
937
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
938
|
+
version=version,
|
|
939
|
+
operation="record",
|
|
940
|
+
status="recorded",
|
|
941
|
+
)
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
def _log_migration_removed(driver: Any, version: str) -> None:
|
|
945
|
+
"""Log that a migration record was removed."""
|
|
946
|
+
log_with_context(
|
|
947
|
+
logger,
|
|
948
|
+
logging.DEBUG,
|
|
949
|
+
"migration.track",
|
|
950
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
951
|
+
version=version,
|
|
952
|
+
operation="remove",
|
|
953
|
+
status="removed",
|
|
954
|
+
)
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
def _resolve_version_update_miss(driver: Any, old_version: str, new_version: str, applied_versions: "set[str]") -> bool:
|
|
958
|
+
"""Resolve a zero-row version update.
|
|
959
|
+
|
|
960
|
+
Args:
|
|
961
|
+
driver: The database driver in use.
|
|
962
|
+
old_version: Current timestamp version string.
|
|
963
|
+
new_version: New sequential version string.
|
|
964
|
+
applied_versions: Version numbers already recorded in the database.
|
|
965
|
+
|
|
966
|
+
Returns:
|
|
967
|
+
True when the update is a no-op re-run and should be skipped.
|
|
968
|
+
|
|
969
|
+
Raises:
|
|
970
|
+
ValueError: If neither old_version nor new_version found in database.
|
|
971
|
+
"""
|
|
972
|
+
if new_version in applied_versions:
|
|
973
|
+
log_with_context(
|
|
974
|
+
logger,
|
|
975
|
+
logging.DEBUG,
|
|
976
|
+
"migration.track",
|
|
977
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
978
|
+
old_version=old_version,
|
|
979
|
+
new_version=new_version,
|
|
980
|
+
operation="version_update",
|
|
981
|
+
status="skipped",
|
|
982
|
+
)
|
|
983
|
+
return True
|
|
984
|
+
|
|
985
|
+
msg = f"Migration version {old_version} not found in database"
|
|
986
|
+
raise ValueError(msg)
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
def _log_version_updated(driver: Any, old_version: str, new_version: str) -> None:
|
|
990
|
+
"""Log that a migration version record was updated."""
|
|
991
|
+
log_with_context(
|
|
992
|
+
logger,
|
|
993
|
+
logging.INFO,
|
|
994
|
+
"migration.track",
|
|
995
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
996
|
+
old_version=old_version,
|
|
997
|
+
new_version=new_version,
|
|
998
|
+
operation="version_update",
|
|
999
|
+
status="updated",
|
|
1000
|
+
)
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
def _log_squash_recorded(driver: Any, squashed_version: str, replaced_count: int) -> None:
|
|
1004
|
+
"""Log that a squashed migration record was written."""
|
|
1005
|
+
log_with_context(
|
|
1006
|
+
logger,
|
|
1007
|
+
logging.INFO,
|
|
1008
|
+
"migration.track",
|
|
1009
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
1010
|
+
squashed_version=squashed_version,
|
|
1011
|
+
replaced_count=replaced_count,
|
|
1012
|
+
operation="squash",
|
|
1013
|
+
status="recorded",
|
|
1014
|
+
)
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
def _log_commit_skipped(driver: Any, exc: Exception) -> None:
|
|
1018
|
+
"""Log that a commit was skipped because the driver manages autocommit."""
|
|
1019
|
+
log_with_context(
|
|
1020
|
+
logger,
|
|
1021
|
+
logging.DEBUG,
|
|
1022
|
+
"migration.track",
|
|
1023
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
1024
|
+
operation="commit",
|
|
1025
|
+
status="skipped",
|
|
1026
|
+
reason="autocommit",
|
|
1027
|
+
error_type=type(exc).__name__,
|
|
1028
|
+
)
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
def _resolve_current_schema(result: Any) -> str:
|
|
1032
|
+
"""Return the schema name from a ``SELECT current_schema()`` result.
|
|
1033
|
+
|
|
1034
|
+
Raises:
|
|
1035
|
+
MigrationError: If the session has no current schema.
|
|
1036
|
+
"""
|
|
1037
|
+
rows = _extract_catalog_rows(result)
|
|
1038
|
+
schema_name = rows[0].get("schema_name") if rows else None
|
|
1039
|
+
if not isinstance(schema_name, str) or not schema_name:
|
|
1040
|
+
msg = "Cannot resolve the migration tracking schema: current_schema() is NULL; set version_table_schema"
|
|
1041
|
+
raise MigrationError(msg)
|
|
1042
|
+
return schema_name
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
def _validate_pg_relation_rows(rows: "Sequence[Mapping[str, Any]]", version_table: str) -> None:
|
|
1046
|
+
"""Validate pre-existing PostgreSQL tracking relation kind, owner, trigger, rule, and RLS state."""
|
|
1047
|
+
for row in rows:
|
|
1048
|
+
relkind = row.get("relkind")
|
|
1049
|
+
if isinstance(relkind, str) and relkind.strip() not in {"r", "p"}:
|
|
1050
|
+
msg = (
|
|
1051
|
+
f"Migration tracking table '{version_table}' must be an ordinary or partitioned table "
|
|
1052
|
+
f"(found relkind={relkind.strip()!r})"
|
|
1053
|
+
)
|
|
1054
|
+
raise MigrationError(msg)
|
|
1055
|
+
if row.get("owned_by_current_role") is False:
|
|
1056
|
+
msg = (
|
|
1057
|
+
f"Migration tracking table '{version_table}' must be owned by the current role, "
|
|
1058
|
+
"a role it belongs to, or a superuser"
|
|
1059
|
+
)
|
|
1060
|
+
raise MigrationError(msg)
|
|
1061
|
+
has_triggers = row.get("has_user_triggers")
|
|
1062
|
+
if has_triggers is True or (isinstance(has_triggers, int) and has_triggers > 0):
|
|
1063
|
+
msg = f"Migration tracking table '{version_table}' cannot have non-internal triggers attached"
|
|
1064
|
+
raise MigrationError(msg)
|
|
1065
|
+
has_rules = row.get("has_rules")
|
|
1066
|
+
if has_rules is True or (isinstance(has_rules, int) and has_rules > 0):
|
|
1067
|
+
msg = f"Migration tracking table '{version_table}' cannot have rewrite rules attached"
|
|
1068
|
+
raise MigrationError(msg)
|
|
1069
|
+
has_rls = row.get("has_row_security")
|
|
1070
|
+
if has_rls is True or (isinstance(has_rls, int) and has_rls > 0):
|
|
1071
|
+
msg = (
|
|
1072
|
+
f"Migration tracking table '{version_table}' cannot have row-level security active for the current role"
|
|
1073
|
+
)
|
|
1074
|
+
raise MigrationError(msg)
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
def _log_lock_release_failure(driver: Any, lock_name: str, exc: Exception) -> None:
|
|
1078
|
+
"""Log a migration lock release or cleanup error while preserving the caller failure."""
|
|
1079
|
+
log_with_context(
|
|
1080
|
+
logger,
|
|
1081
|
+
logging.WARNING,
|
|
1082
|
+
"migration.lock.release_failed",
|
|
1083
|
+
db_system=resolve_db_system(type(driver).__name__),
|
|
1084
|
+
lock_name=lock_name,
|
|
1085
|
+
error_type=type(exc).__name__,
|
|
1086
|
+
)
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
def _is_postgres_lock_acquired(result: Any) -> bool:
|
|
1090
|
+
"""Return True when a ``pg_try_advisory_lock`` result reports ownership."""
|
|
1091
|
+
if result is None:
|
|
1092
|
+
return False
|
|
1093
|
+
if isinstance(result, bool):
|
|
1094
|
+
return result
|
|
1095
|
+
rows = _extract_catalog_rows(result)
|
|
1096
|
+
if rows:
|
|
1097
|
+
return bool(next(iter(rows[0].values()), False))
|
|
1098
|
+
data = getattr(result, "data", None)
|
|
1099
|
+
if isinstance(data, Sequence) and not isinstance(data, (str, bytes)) and data:
|
|
1100
|
+
first_row = data[0]
|
|
1101
|
+
if isinstance(first_row, Sequence) and not isinstance(first_row, (str, bytes)) and first_row:
|
|
1102
|
+
return bool(first_row[0])
|
|
1103
|
+
scalar_or_none = getattr(result, "scalar_or_none", None)
|
|
1104
|
+
if callable(scalar_or_none):
|
|
1105
|
+
value = scalar_or_none()
|
|
1106
|
+
if isinstance(value, (bool, int)):
|
|
1107
|
+
return bool(value)
|
|
1108
|
+
return False
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
def _wall_clock_ms() -> int:
|
|
1112
|
+
"""Return the client wall clock in epoch milliseconds."""
|
|
1113
|
+
return int(_time() * _MILLISECONDS_PER_SECOND)
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
def _lease_timeout_error(lock_name: str, timeout_seconds: int) -> MigrationError:
|
|
1117
|
+
"""Build a ``MigrationError`` for lease lock acquisition timeout."""
|
|
1118
|
+
msg = f"Failed to acquire migration lock {lock_name!r} within {timeout_seconds}s; another migrator holds the lease"
|
|
1119
|
+
return MigrationError(msg)
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
def _lease_expired_error() -> MigrationError:
|
|
1123
|
+
"""Build a ``MigrationError`` for a renewal that found no lease row."""
|
|
1124
|
+
return MigrationError("Migration lock lease expired; another migrator may have taken over")
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
def _postgres_lock_timeout_error(lock_name: str, timeout_seconds: int) -> MigrationError:
|
|
1128
|
+
"""Build a ``MigrationError`` for PostgreSQL advisory lock acquisition timeout."""
|
|
1129
|
+
msg = f"Failed to acquire PostgreSQL migration lock {lock_name!r} within {timeout_seconds}s"
|
|
1130
|
+
return MigrationError(msg)
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1134
|
+
class _SyncMigrationLockContext:
|
|
1135
|
+
"""Slotted synchronous migration lock context manager."""
|
|
1136
|
+
|
|
1137
|
+
__slots__ = (
|
|
1138
|
+
"_driver",
|
|
1139
|
+
"_driver_id",
|
|
1140
|
+
"_lock_id",
|
|
1141
|
+
"_lock_kind",
|
|
1142
|
+
"_lock_name",
|
|
1143
|
+
"_owner_token",
|
|
1144
|
+
"_sqlite_locked",
|
|
1145
|
+
"_timeout_seconds",
|
|
1146
|
+
"_tracker",
|
|
1147
|
+
)
|
|
1148
|
+
|
|
1149
|
+
def __init__(self, tracker: "SyncMigrationTracker", driver: Any, *, timeout_seconds: int = 30) -> None:
|
|
1150
|
+
self._tracker = tracker
|
|
1151
|
+
self._driver = driver
|
|
1152
|
+
self._timeout_seconds = timeout_seconds
|
|
1153
|
+
self._lock_kind = tracker._resolve_lock_backend(driver)
|
|
1154
|
+
self._lock_name = ""
|
|
1155
|
+
self._lock_id = 0
|
|
1156
|
+
self._driver_id = id(driver)
|
|
1157
|
+
self._owner_token = ""
|
|
1158
|
+
self._sqlite_locked = False
|
|
1159
|
+
|
|
1160
|
+
def __enter__(self) -> None:
|
|
1161
|
+
if not self._lock_kind:
|
|
1162
|
+
return
|
|
1163
|
+
if self._lock_kind == "unsupported":
|
|
1164
|
+
self._tracker._warn_unsupported_lock(self._driver)
|
|
1165
|
+
return
|
|
1166
|
+
self._lock_name, self._lock_id = self._tracker._migration_lock_key()
|
|
1167
|
+
if self._lock_kind == "lease":
|
|
1168
|
+
self._enter_lease()
|
|
1169
|
+
return
|
|
1170
|
+
if self._lock_kind == "postgres":
|
|
1171
|
+
timeout_seconds = max(self._timeout_seconds, 0)
|
|
1172
|
+
deadline = _monotonic() + timeout_seconds
|
|
1173
|
+
while True:
|
|
1174
|
+
lock_result = self._driver.execute(
|
|
1175
|
+
"SELECT pg_try_advisory_lock(:lock_id) AS acquired", {"lock_id": self._lock_id}
|
|
1176
|
+
)
|
|
1177
|
+
if _is_postgres_lock_acquired(lock_result):
|
|
1178
|
+
try:
|
|
1179
|
+
self._tracker._recheck_tracking_relation_sync(self._driver)
|
|
1180
|
+
except MigrationError:
|
|
1181
|
+
self._release_postgres_lock(True)
|
|
1182
|
+
raise
|
|
1183
|
+
return
|
|
1184
|
+
remaining = deadline - _monotonic()
|
|
1185
|
+
if remaining <= 0:
|
|
1186
|
+
raise _postgres_lock_timeout_error(self._lock_name, timeout_seconds)
|
|
1187
|
+
_sleep(min(_POSTGRES_LOCK_POLL_INTERVAL_SECONDS, remaining))
|
|
1188
|
+
if self._lock_kind == "mysql":
|
|
1189
|
+
lock_result = self._driver.select_value(
|
|
1190
|
+
"SELECT GET_LOCK(:lock_name, :timeout)",
|
|
1191
|
+
{"lock_name": self._lock_name, "timeout": max(self._timeout_seconds, 0)},
|
|
1192
|
+
)
|
|
1193
|
+
self._tracker._validate_mysql_lock_result(self._lock_name, self._timeout_seconds, lock_result)
|
|
1194
|
+
return
|
|
1195
|
+
if self._lock_kind == "mssql":
|
|
1196
|
+
timeout_ms = max(self._timeout_seconds, 0) * _MILLISECONDS_PER_SECOND
|
|
1197
|
+
try:
|
|
1198
|
+
ms_result = self._driver.execute(
|
|
1199
|
+
self._tracker._MSSQL_ACQUIRE_LOCK_SQL, {"lock_name": self._lock_name, "timeout_ms": timeout_ms}
|
|
1200
|
+
)
|
|
1201
|
+
except SQLSpecError as exc:
|
|
1202
|
+
translated = self._tracker._translate_mssql_lock_exception(self._lock_name, self._timeout_seconds, exc)
|
|
1203
|
+
if translated is not None:
|
|
1204
|
+
translated.__cause__ = exc
|
|
1205
|
+
raise translated from exc
|
|
1206
|
+
raise
|
|
1207
|
+
self._tracker._validate_mssql_lock_result(self._lock_name, ms_result)
|
|
1208
|
+
return
|
|
1209
|
+
if self._lock_kind == "sqlite":
|
|
1210
|
+
if self._driver._connection_in_transaction(): # pyright: ignore[reportPrivateUsage]
|
|
1211
|
+
return
|
|
1212
|
+
self._driver.execute("BEGIN IMMEDIATE")
|
|
1213
|
+
self._tracker._sqlite_lock_owners.add(self._driver_id)
|
|
1214
|
+
self._sqlite_locked = True
|
|
1215
|
+
|
|
1216
|
+
def _enter_lease(self) -> None:
|
|
1217
|
+
tracker = self._tracker
|
|
1218
|
+
target = tracker._lock_schema_target()
|
|
1219
|
+
try:
|
|
1220
|
+
ensure_schema_sync(self._driver, [target], manage_schema=True, commit=True)
|
|
1221
|
+
except SQLSpecError:
|
|
1222
|
+
with suppress(Exception):
|
|
1223
|
+
if _driver_in_transaction_sync(self._driver):
|
|
1224
|
+
self._driver.rollback()
|
|
1225
|
+
ensure_schema_sync(self._driver, [target], manage_schema=True, commit=True)
|
|
1226
|
+
owner_token = uuid4().hex
|
|
1227
|
+
timeout_seconds = max(self._timeout_seconds, 0)
|
|
1228
|
+
deadline = _monotonic() + timeout_seconds
|
|
1229
|
+
lease_ms = tracker.lock_lease_seconds * _MILLISECONDS_PER_SECOND
|
|
1230
|
+
while True:
|
|
1231
|
+
now_ms = _wall_clock_ms()
|
|
1232
|
+
try:
|
|
1233
|
+
self._driver.execute(tracker._lease_delete_expired(self._lock_name, now_ms))
|
|
1234
|
+
self._driver.execute(tracker._lease_insert(self._lock_name, owner_token, now_ms + lease_ms))
|
|
1235
|
+
tracker._safe_commit(self._driver)
|
|
1236
|
+
except (IntegrityError, SerializationConflictError):
|
|
1237
|
+
with suppress(Exception):
|
|
1238
|
+
if _driver_in_transaction_sync(self._driver):
|
|
1239
|
+
self._driver.rollback()
|
|
1240
|
+
remaining = deadline - _monotonic()
|
|
1241
|
+
if remaining <= 0:
|
|
1242
|
+
raise with_cause(_lease_timeout_error(self._lock_name, timeout_seconds), None) from None
|
|
1243
|
+
_sleep(min(_LEASE_LOCK_POLL_INTERVAL_SECONDS, remaining))
|
|
1244
|
+
continue
|
|
1245
|
+
self._owner_token = owner_token
|
|
1246
|
+
tracker._lease_owners[self._driver_id] = (self._lock_name, owner_token)
|
|
1247
|
+
return
|
|
1248
|
+
|
|
1249
|
+
def _exit_lease(self, has_error: bool) -> None:
|
|
1250
|
+
self._tracker._lease_owners.pop(self._driver_id, None)
|
|
1251
|
+
if has_error:
|
|
1252
|
+
with suppress(Exception):
|
|
1253
|
+
if _driver_in_transaction_sync(self._driver):
|
|
1254
|
+
self._driver.rollback()
|
|
1255
|
+
try:
|
|
1256
|
+
self._release_lease()
|
|
1257
|
+
except Exception as unlock_exc:
|
|
1258
|
+
_log_lock_release_failure(self._driver, self._lock_name, unlock_exc)
|
|
1259
|
+
return
|
|
1260
|
+
self._release_lease()
|
|
1261
|
+
|
|
1262
|
+
def _release_lease(self) -> None:
|
|
1263
|
+
holder = self._tracker._lease_holder(self._driver.execute(self._tracker._lease_owner_query(self._lock_name)))
|
|
1264
|
+
self._driver.execute(self._tracker._lease_release(self._lock_name, self._owner_token))
|
|
1265
|
+
self._tracker._safe_commit(self._driver)
|
|
1266
|
+
if holder is None or holder[0] != self._owner_token:
|
|
1267
|
+
raise _lease_expired_error()
|
|
1268
|
+
|
|
1269
|
+
def __exit__(
|
|
1270
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
1271
|
+
) -> Literal[False]:
|
|
1272
|
+
if not self._lock_kind:
|
|
1273
|
+
return False
|
|
1274
|
+
has_error = exc_type is not None
|
|
1275
|
+
if self._lock_kind == "lease":
|
|
1276
|
+
self._exit_lease(has_error)
|
|
1277
|
+
return False
|
|
1278
|
+
if self._lock_kind == "postgres":
|
|
1279
|
+
self._release_postgres_lock(has_error)
|
|
1280
|
+
return False
|
|
1281
|
+
if self._lock_kind == "mysql":
|
|
1282
|
+
self._release_named_lock("SELECT RELEASE_LOCK(:lock_name)", {"lock_name": self._lock_name}, has_error)
|
|
1283
|
+
return False
|
|
1284
|
+
if self._lock_kind == "mssql":
|
|
1285
|
+
self._release_named_lock(self._tracker._MSSQL_RELEASE_LOCK_SQL, {"lock_name": self._lock_name}, has_error)
|
|
1286
|
+
return False
|
|
1287
|
+
if self._lock_kind == "sqlite" and self._sqlite_locked:
|
|
1288
|
+
self._release_sqlite_lock(has_error)
|
|
1289
|
+
return False
|
|
1290
|
+
|
|
1291
|
+
def _release_postgres_lock(self, has_error: bool) -> None:
|
|
1292
|
+
if has_error:
|
|
1293
|
+
with suppress(Exception):
|
|
1294
|
+
if _driver_in_transaction_sync(self._driver):
|
|
1295
|
+
self._driver.rollback()
|
|
1296
|
+
try:
|
|
1297
|
+
self._driver.execute("SELECT pg_advisory_unlock(:lock_id)", {"lock_id": self._lock_id})
|
|
1298
|
+
except Exception as unlock_exc:
|
|
1299
|
+
_log_lock_release_failure(self._driver, self._lock_name, unlock_exc)
|
|
1300
|
+
return
|
|
1301
|
+
self._driver.execute("SELECT pg_advisory_unlock(:lock_id)", {"lock_id": self._lock_id})
|
|
1302
|
+
|
|
1303
|
+
def _release_named_lock(self, sql_stmt: str, params: "dict[str, Any]", has_error: bool) -> None:
|
|
1304
|
+
if has_error:
|
|
1305
|
+
try:
|
|
1306
|
+
self._driver.execute(sql_stmt, params)
|
|
1307
|
+
except Exception as unlock_exc:
|
|
1308
|
+
_log_lock_release_failure(self._driver, self._lock_name, unlock_exc)
|
|
1309
|
+
return
|
|
1310
|
+
self._driver.execute(sql_stmt, params)
|
|
1311
|
+
|
|
1312
|
+
def _release_sqlite_lock(self, has_error: bool) -> None:
|
|
1313
|
+
self._sqlite_locked = False
|
|
1314
|
+
self._tracker._sqlite_lock_owners.discard(self._driver_id)
|
|
1315
|
+
if has_error:
|
|
1316
|
+
try:
|
|
1317
|
+
if self._driver._connection_in_transaction(): # pyright: ignore[reportPrivateUsage]
|
|
1318
|
+
self._driver.rollback()
|
|
1319
|
+
except Exception as rollback_exc:
|
|
1320
|
+
_log_lock_release_failure(self._driver, self._lock_name, rollback_exc)
|
|
1321
|
+
return
|
|
1322
|
+
if self._driver._connection_in_transaction(): # pyright: ignore[reportPrivateUsage]
|
|
1323
|
+
self._driver.commit()
|
|
1324
|
+
|
|
1325
|
+
|
|
1326
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1327
|
+
class _AsyncMigrationLockContext:
|
|
1328
|
+
"""Slotted asynchronous migration lock context manager."""
|
|
1329
|
+
|
|
1330
|
+
__slots__ = (
|
|
1331
|
+
"_driver",
|
|
1332
|
+
"_driver_id",
|
|
1333
|
+
"_lock_id",
|
|
1334
|
+
"_lock_kind",
|
|
1335
|
+
"_lock_name",
|
|
1336
|
+
"_owner_token",
|
|
1337
|
+
"_sqlite_locked",
|
|
1338
|
+
"_timeout_seconds",
|
|
1339
|
+
"_tracker",
|
|
1340
|
+
)
|
|
1341
|
+
|
|
1342
|
+
def __init__(self, tracker: "AsyncMigrationTracker", driver: Any, *, timeout_seconds: int = 30) -> None:
|
|
1343
|
+
self._tracker = tracker
|
|
1344
|
+
self._driver = driver
|
|
1345
|
+
self._timeout_seconds = timeout_seconds
|
|
1346
|
+
self._lock_kind = tracker._resolve_lock_backend(driver)
|
|
1347
|
+
self._lock_name = ""
|
|
1348
|
+
self._lock_id = 0
|
|
1349
|
+
self._driver_id = id(driver)
|
|
1350
|
+
self._owner_token = ""
|
|
1351
|
+
self._sqlite_locked = False
|
|
1352
|
+
|
|
1353
|
+
async def __aenter__(self) -> None:
|
|
1354
|
+
if not self._lock_kind:
|
|
1355
|
+
return
|
|
1356
|
+
if self._lock_kind == "unsupported":
|
|
1357
|
+
self._tracker._warn_unsupported_lock(self._driver)
|
|
1358
|
+
return
|
|
1359
|
+
self._lock_name, self._lock_id = self._tracker._migration_lock_key()
|
|
1360
|
+
if self._lock_kind == "lease":
|
|
1361
|
+
await self._enter_lease()
|
|
1362
|
+
return
|
|
1363
|
+
if self._lock_kind == "postgres":
|
|
1364
|
+
timeout_seconds = max(self._timeout_seconds, 0)
|
|
1365
|
+
deadline = _monotonic() + timeout_seconds
|
|
1366
|
+
while True:
|
|
1367
|
+
lock_result = await self._driver.execute(
|
|
1368
|
+
"SELECT pg_try_advisory_lock(:lock_id) AS acquired", {"lock_id": self._lock_id}
|
|
1369
|
+
)
|
|
1370
|
+
if _is_postgres_lock_acquired(lock_result):
|
|
1371
|
+
recheck_error: MigrationError | None = None
|
|
1372
|
+
try:
|
|
1373
|
+
await self._tracker._recheck_tracking_relation_async(self._driver)
|
|
1374
|
+
except MigrationError as exc:
|
|
1375
|
+
recheck_error = exc
|
|
1376
|
+
if recheck_error is not None:
|
|
1377
|
+
await self._release_postgres_lock(True)
|
|
1378
|
+
raise recheck_error
|
|
1379
|
+
return
|
|
1380
|
+
remaining = deadline - _monotonic()
|
|
1381
|
+
if remaining <= 0:
|
|
1382
|
+
raise _postgres_lock_timeout_error(self._lock_name, timeout_seconds)
|
|
1383
|
+
await _async_sleep(min(_POSTGRES_LOCK_POLL_INTERVAL_SECONDS, remaining))
|
|
1384
|
+
if self._lock_kind == "mysql":
|
|
1385
|
+
lock_result = await self._driver.select_value(
|
|
1386
|
+
"SELECT GET_LOCK(:lock_name, :timeout)",
|
|
1387
|
+
{"lock_name": self._lock_name, "timeout": max(self._timeout_seconds, 0)},
|
|
1388
|
+
)
|
|
1389
|
+
self._tracker._validate_mysql_lock_result(self._lock_name, self._timeout_seconds, lock_result)
|
|
1390
|
+
return
|
|
1391
|
+
if self._lock_kind == "mssql":
|
|
1392
|
+
timeout_ms = max(self._timeout_seconds, 0) * _MILLISECONDS_PER_SECOND
|
|
1393
|
+
try:
|
|
1394
|
+
ms_result = await self._driver.execute(
|
|
1395
|
+
self._tracker._MSSQL_ACQUIRE_LOCK_SQL, {"lock_name": self._lock_name, "timeout_ms": timeout_ms}
|
|
1396
|
+
)
|
|
1397
|
+
except SQLSpecError as exc:
|
|
1398
|
+
translated = self._tracker._translate_mssql_lock_exception(self._lock_name, self._timeout_seconds, exc)
|
|
1399
|
+
if translated is not None:
|
|
1400
|
+
translated.__cause__ = exc
|
|
1401
|
+
raise translated from exc
|
|
1402
|
+
raise
|
|
1403
|
+
self._tracker._validate_mssql_lock_result(self._lock_name, ms_result)
|
|
1404
|
+
return
|
|
1405
|
+
if self._lock_kind == "sqlite":
|
|
1406
|
+
if await _driver_in_transaction_async(self._driver):
|
|
1407
|
+
return
|
|
1408
|
+
await self._driver.execute("BEGIN IMMEDIATE")
|
|
1409
|
+
self._tracker._sqlite_lock_owners.add(self._driver_id)
|
|
1410
|
+
self._sqlite_locked = True
|
|
1411
|
+
|
|
1412
|
+
async def _enter_lease(self) -> None:
|
|
1413
|
+
tracker = self._tracker
|
|
1414
|
+
target = tracker._lock_schema_target()
|
|
1415
|
+
lease_error: SQLSpecError | None = None
|
|
1416
|
+
try:
|
|
1417
|
+
await ensure_schema_async(self._driver, [target], manage_schema=True, commit=True)
|
|
1418
|
+
except SQLSpecError as exc:
|
|
1419
|
+
lease_error = exc
|
|
1420
|
+
if lease_error is not None:
|
|
1421
|
+
with suppress(Exception):
|
|
1422
|
+
if await _driver_in_transaction_async(self._driver):
|
|
1423
|
+
await self._driver.rollback()
|
|
1424
|
+
await ensure_schema_async(self._driver, [target], manage_schema=True, commit=True)
|
|
1425
|
+
owner_token = uuid4().hex
|
|
1426
|
+
timeout_seconds = max(self._timeout_seconds, 0)
|
|
1427
|
+
deadline = _monotonic() + timeout_seconds
|
|
1428
|
+
lease_ms = tracker.lock_lease_seconds * _MILLISECONDS_PER_SECOND
|
|
1429
|
+
while True:
|
|
1430
|
+
now_ms = _wall_clock_ms()
|
|
1431
|
+
claim_error: IntegrityError | SerializationConflictError | None = None
|
|
1432
|
+
try:
|
|
1433
|
+
await self._driver.execute(tracker._lease_delete_expired(self._lock_name, now_ms))
|
|
1434
|
+
await self._driver.execute(tracker._lease_insert(self._lock_name, owner_token, now_ms + lease_ms))
|
|
1435
|
+
await tracker._safe_commit(self._driver)
|
|
1436
|
+
except (IntegrityError, SerializationConflictError) as exc:
|
|
1437
|
+
claim_error = exc
|
|
1438
|
+
if claim_error is not None:
|
|
1439
|
+
with suppress(Exception):
|
|
1440
|
+
if await _driver_in_transaction_async(self._driver):
|
|
1441
|
+
await self._driver.rollback()
|
|
1442
|
+
remaining = deadline - _monotonic()
|
|
1443
|
+
if remaining <= 0:
|
|
1444
|
+
raise with_cause(_lease_timeout_error(self._lock_name, timeout_seconds), None) from None
|
|
1445
|
+
await _async_sleep(min(_LEASE_LOCK_POLL_INTERVAL_SECONDS, remaining))
|
|
1446
|
+
continue
|
|
1447
|
+
self._owner_token = owner_token
|
|
1448
|
+
tracker._lease_owners[self._driver_id] = (self._lock_name, owner_token)
|
|
1449
|
+
return
|
|
1450
|
+
|
|
1451
|
+
async def _exit_lease(self, has_error: bool) -> None:
|
|
1452
|
+
self._tracker._lease_owners.pop(self._driver_id, None)
|
|
1453
|
+
if has_error:
|
|
1454
|
+
with suppress(Exception):
|
|
1455
|
+
if await _driver_in_transaction_async(self._driver):
|
|
1456
|
+
await self._driver.rollback()
|
|
1457
|
+
try:
|
|
1458
|
+
await self._release_lease()
|
|
1459
|
+
except Exception as unlock_exc:
|
|
1460
|
+
_log_lock_release_failure(self._driver, self._lock_name, unlock_exc)
|
|
1461
|
+
return
|
|
1462
|
+
await self._release_lease()
|
|
1463
|
+
|
|
1464
|
+
async def _release_lease(self) -> None:
|
|
1465
|
+
holder = self._tracker._lease_holder(
|
|
1466
|
+
await self._driver.execute(self._tracker._lease_owner_query(self._lock_name))
|
|
1467
|
+
)
|
|
1468
|
+
await self._driver.execute(self._tracker._lease_release(self._lock_name, self._owner_token))
|
|
1469
|
+
await self._tracker._safe_commit(self._driver)
|
|
1470
|
+
if holder is None or holder[0] != self._owner_token:
|
|
1471
|
+
raise _lease_expired_error()
|
|
1472
|
+
|
|
1473
|
+
async def __aexit__(
|
|
1474
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
1475
|
+
) -> Literal[False]:
|
|
1476
|
+
if not self._lock_kind:
|
|
1477
|
+
return False
|
|
1478
|
+
has_error = exc_type is not None
|
|
1479
|
+
if self._lock_kind == "lease":
|
|
1480
|
+
await self._exit_lease(has_error)
|
|
1481
|
+
return False
|
|
1482
|
+
if self._lock_kind == "postgres":
|
|
1483
|
+
await self._release_postgres_lock(has_error)
|
|
1484
|
+
return False
|
|
1485
|
+
if self._lock_kind == "mysql":
|
|
1486
|
+
await self._release_named_lock("SELECT RELEASE_LOCK(:lock_name)", {"lock_name": self._lock_name}, has_error)
|
|
1487
|
+
return False
|
|
1488
|
+
if self._lock_kind == "mssql":
|
|
1489
|
+
await self._release_named_lock(
|
|
1490
|
+
self._tracker._MSSQL_RELEASE_LOCK_SQL, {"lock_name": self._lock_name}, has_error
|
|
1491
|
+
)
|
|
1492
|
+
return False
|
|
1493
|
+
if self._lock_kind == "sqlite" and self._sqlite_locked:
|
|
1494
|
+
await self._release_sqlite_lock(has_error)
|
|
1495
|
+
return False
|
|
1496
|
+
|
|
1497
|
+
async def _release_postgres_lock(self, has_error: bool) -> None:
|
|
1498
|
+
if has_error:
|
|
1499
|
+
with suppress(Exception):
|
|
1500
|
+
if await _driver_in_transaction_async(self._driver):
|
|
1501
|
+
await self._driver.rollback()
|
|
1502
|
+
try:
|
|
1503
|
+
await self._driver.execute("SELECT pg_advisory_unlock(:lock_id)", {"lock_id": self._lock_id})
|
|
1504
|
+
except Exception as unlock_exc:
|
|
1505
|
+
_log_lock_release_failure(self._driver, self._lock_name, unlock_exc)
|
|
1506
|
+
return
|
|
1507
|
+
await self._driver.execute("SELECT pg_advisory_unlock(:lock_id)", {"lock_id": self._lock_id})
|
|
1508
|
+
|
|
1509
|
+
async def _release_named_lock(self, sql_stmt: str, params: "dict[str, Any]", has_error: bool) -> None:
|
|
1510
|
+
if has_error:
|
|
1511
|
+
try:
|
|
1512
|
+
await self._driver.execute(sql_stmt, params)
|
|
1513
|
+
except Exception as unlock_exc:
|
|
1514
|
+
_log_lock_release_failure(self._driver, self._lock_name, unlock_exc)
|
|
1515
|
+
return
|
|
1516
|
+
await self._driver.execute(sql_stmt, params)
|
|
1517
|
+
|
|
1518
|
+
async def _release_sqlite_lock(self, has_error: bool) -> None:
|
|
1519
|
+
self._sqlite_locked = False
|
|
1520
|
+
self._tracker._sqlite_lock_owners.discard(self._driver_id)
|
|
1521
|
+
if has_error:
|
|
1522
|
+
try:
|
|
1523
|
+
if await _driver_in_transaction_async(self._driver):
|
|
1524
|
+
await self._driver.rollback()
|
|
1525
|
+
except Exception as rollback_exc:
|
|
1526
|
+
_log_lock_release_failure(self._driver, self._lock_name, rollback_exc)
|
|
1527
|
+
return
|
|
1528
|
+
if await _driver_in_transaction_async(self._driver):
|
|
1529
|
+
await self._driver.commit()
|