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
sqlspec/cli.py
ADDED
|
@@ -0,0 +1,1656 @@
|
|
|
1
|
+
# ruff: noqa: C901
|
|
2
|
+
"""Command-line interface for SQLSpec database migrations and extension management."""
|
|
3
|
+
|
|
4
|
+
import inspect
|
|
5
|
+
import sys
|
|
6
|
+
from collections.abc import Callable, Sequence
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import TYPE_CHECKING, Any, Literal, TypeAlias, cast
|
|
9
|
+
|
|
10
|
+
import rich_click as click
|
|
11
|
+
from rich import get_console
|
|
12
|
+
from rich.console import Console
|
|
13
|
+
from rich.markup import escape
|
|
14
|
+
from rich.prompt import Confirm, Prompt
|
|
15
|
+
from rich.table import Table
|
|
16
|
+
|
|
17
|
+
from sqlspec.config import AsyncDatabaseConfig, NoPoolAsyncConfig, NoPoolSyncConfig, SyncDatabaseConfig
|
|
18
|
+
from sqlspec.exceptions import SQLSpecError
|
|
19
|
+
from sqlspec.migrations import commands as migration_commands_module
|
|
20
|
+
from sqlspec.migrations.squash import parse_version_range
|
|
21
|
+
from sqlspec.utils.adapters import resolve_adapter_name
|
|
22
|
+
from sqlspec.utils.config_tools import discover_config_from_pyproject, resolve_config_sync
|
|
23
|
+
from sqlspec.utils.logging import get_logger
|
|
24
|
+
from sqlspec.utils.sync_tools import run_
|
|
25
|
+
|
|
26
|
+
if TYPE_CHECKING:
|
|
27
|
+
from rich_click import Group
|
|
28
|
+
|
|
29
|
+
from sqlspec.extensions.adk.memory.store import BaseAsyncADKMemoryStore, BaseSyncADKMemoryStore
|
|
30
|
+
from sqlspec.migrations.commands import AsyncMigrationCommands, SyncMigrationCommands
|
|
31
|
+
|
|
32
|
+
cli: Group
|
|
33
|
+
|
|
34
|
+
__all__ = ("add_migration_commands", "cli", "get_sqlspec_group")
|
|
35
|
+
|
|
36
|
+
AnyDatabaseConfig: TypeAlias = (
|
|
37
|
+
AsyncDatabaseConfig[Any, Any, Any]
|
|
38
|
+
| SyncDatabaseConfig[Any, Any, Any]
|
|
39
|
+
| NoPoolAsyncConfig[Any, Any]
|
|
40
|
+
| NoPoolSyncConfig[Any, Any]
|
|
41
|
+
)
|
|
42
|
+
logger = get_logger("cli")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_sqlspec_group() -> "Group":
|
|
46
|
+
"""Get the SQLSpec CLI group.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
The SQLSpec CLI group.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
@click.group(name="sqlspec", cls=_SQLSpecGroup, context_settings={"help_option_names": ["-h", "--help"]})
|
|
53
|
+
@click.option(
|
|
54
|
+
"--config",
|
|
55
|
+
help="Dotted path to SQLSpec config(s) or callable function (env: SQLSPEC_CONFIG)",
|
|
56
|
+
required=False,
|
|
57
|
+
default=None,
|
|
58
|
+
type=str,
|
|
59
|
+
envvar="SQLSPEC_CONFIG",
|
|
60
|
+
)
|
|
61
|
+
@click.option(
|
|
62
|
+
"--validate-config", is_flag=True, default=False, help="Validate configuration before executing migrations"
|
|
63
|
+
)
|
|
64
|
+
@click.pass_context
|
|
65
|
+
def sqlspec_group(ctx: "click.Context", config: str | None, validate_config: bool) -> None:
|
|
66
|
+
"""SQLSpec CLI commands.
|
|
67
|
+
|
|
68
|
+
Configuration resolution prefers CLI flag, SQLSPEC_CONFIG env var, and finally the [tool.sqlspec] section.
|
|
69
|
+
Comma-separated paths are split, deduplicated by bind key, and loaded from the current working directory so local modules can be imported.
|
|
70
|
+
When --validate-config is used we report each config's async capability.
|
|
71
|
+
"""
|
|
72
|
+
console = get_console()
|
|
73
|
+
ctx.ensure_object(dict)
|
|
74
|
+
|
|
75
|
+
if _should_skip_config_resolution(ctx):
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
if config is None:
|
|
79
|
+
config = discover_config_from_pyproject()
|
|
80
|
+
if config:
|
|
81
|
+
console.print("[dim]Using config from pyproject.toml[/]")
|
|
82
|
+
|
|
83
|
+
if config is None:
|
|
84
|
+
console.print("[red]Error: No SQLSpec config found.[/]")
|
|
85
|
+
console.print("\nSpecify config using one of:")
|
|
86
|
+
console.print(" 1. CLI flag: sqlspec --config myapp.config:get_configs <command>")
|
|
87
|
+
console.print(" 2. Environment var: export SQLSPEC_CONFIG=myapp.config:get_configs")
|
|
88
|
+
console.print(f" 3. pyproject.toml: {escape('[tool.sqlspec]')}")
|
|
89
|
+
console.print(' config = "myapp.config:get_configs"')
|
|
90
|
+
ctx.exit(1)
|
|
91
|
+
|
|
92
|
+
cwd = str(Path.cwd())
|
|
93
|
+
cwd_added = False
|
|
94
|
+
if cwd not in sys.path:
|
|
95
|
+
sys.path.insert(0, cwd)
|
|
96
|
+
cwd_added = True
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
all_configs: list[AnyDatabaseConfig] = []
|
|
100
|
+
for config_path in config.split(","):
|
|
101
|
+
config_path = config_path.strip()
|
|
102
|
+
if not config_path:
|
|
103
|
+
continue
|
|
104
|
+
config_result = resolve_config_sync(config_path)
|
|
105
|
+
if isinstance(config_result, Sequence) and not isinstance(config_result, str):
|
|
106
|
+
all_configs.extend(config_result)
|
|
107
|
+
else:
|
|
108
|
+
all_configs.append(config_result) # pyright: ignore
|
|
109
|
+
|
|
110
|
+
configs_list: list[AnyDatabaseConfig] = []
|
|
111
|
+
seen_bind_keys: dict[str, int] = {}
|
|
112
|
+
for cfg in all_configs:
|
|
113
|
+
if cfg.bind_key is not None and cfg.bind_key in seen_bind_keys:
|
|
114
|
+
configs_list[seen_bind_keys[cfg.bind_key]] = cfg
|
|
115
|
+
else:
|
|
116
|
+
if cfg.bind_key is not None:
|
|
117
|
+
seen_bind_keys[cfg.bind_key] = len(configs_list)
|
|
118
|
+
configs_list.append(cfg)
|
|
119
|
+
|
|
120
|
+
ctx.obj["configs"] = configs_list
|
|
121
|
+
|
|
122
|
+
if not ctx.obj["configs"]:
|
|
123
|
+
console.print("[red]Error: No valid configs found after resolution.[/]")
|
|
124
|
+
console.print("\nEnsure your config path returns valid config instance(s).")
|
|
125
|
+
ctx.exit(1)
|
|
126
|
+
|
|
127
|
+
ctx.obj["validate_config"] = validate_config
|
|
128
|
+
|
|
129
|
+
if validate_config:
|
|
130
|
+
console.print(f"[green]✓[/] Successfully loaded {len(ctx.obj['configs'])} config(s)")
|
|
131
|
+
for i, cfg in enumerate(ctx.obj["configs"]):
|
|
132
|
+
config_name = cfg.bind_key or f"config-{i}"
|
|
133
|
+
config_type = type(cfg).__name__
|
|
134
|
+
is_async = cfg.is_async
|
|
135
|
+
execution_hint = "[dim cyan](async-capable)[/]" if is_async else "[dim](sync)[/]"
|
|
136
|
+
console.print(f" [dim]•[/] {config_name}: {config_type} {execution_hint}")
|
|
137
|
+
|
|
138
|
+
except (ImportError, SQLSpecError) as e:
|
|
139
|
+
console.print(f"[red]Error loading config: {escape(str(e))}[/]", emoji=False)
|
|
140
|
+
ctx.exit(1)
|
|
141
|
+
finally:
|
|
142
|
+
if cwd_added and cwd in sys.path and sys.path[0] == cwd:
|
|
143
|
+
sys.path.remove(cwd)
|
|
144
|
+
|
|
145
|
+
return sqlspec_group
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def add_migration_commands(database_group: "Group | None" = None) -> "Group":
|
|
149
|
+
"""Add migration commands to the database group.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
database_group: The database group to add the commands to.
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
The database group with the migration commands added.
|
|
156
|
+
"""
|
|
157
|
+
console = get_console()
|
|
158
|
+
|
|
159
|
+
if database_group is None:
|
|
160
|
+
database_group = get_sqlspec_group()
|
|
161
|
+
|
|
162
|
+
bind_key_option = click.option(
|
|
163
|
+
"--bind-key", help="Specify which SQLSpec config to use by bind key", type=str, default=None
|
|
164
|
+
)
|
|
165
|
+
verbose_option = click.option("--verbose", help="Enable verbose output.", type=bool, default=False, is_flag=True)
|
|
166
|
+
no_prompt_option = click.option(
|
|
167
|
+
"--no-prompt",
|
|
168
|
+
help="Do not prompt for confirmation before executing the command.",
|
|
169
|
+
type=bool,
|
|
170
|
+
default=False,
|
|
171
|
+
required=False,
|
|
172
|
+
show_default=True,
|
|
173
|
+
is_flag=True,
|
|
174
|
+
)
|
|
175
|
+
include_option = click.option(
|
|
176
|
+
"--include", multiple=True, help="Include only specific configurations (can be used multiple times)"
|
|
177
|
+
)
|
|
178
|
+
exclude_option = click.option(
|
|
179
|
+
"--exclude", multiple=True, help="Exclude specific configurations (can be used multiple times)"
|
|
180
|
+
)
|
|
181
|
+
dry_run_option = click.option(
|
|
182
|
+
"--dry-run", is_flag=True, default=False, help="Show what would be executed without making changes"
|
|
183
|
+
)
|
|
184
|
+
use_logger_option = click.option(
|
|
185
|
+
"--use-logger",
|
|
186
|
+
is_flag=True,
|
|
187
|
+
default=False,
|
|
188
|
+
help="Emit migration output via structured logger instead of console output",
|
|
189
|
+
)
|
|
190
|
+
no_echo_option = click.option(
|
|
191
|
+
"--no-echo", is_flag=True, default=False, help="Disable console output for migration commands"
|
|
192
|
+
)
|
|
193
|
+
summary_only_option = click.option(
|
|
194
|
+
"--summary",
|
|
195
|
+
"summary_only",
|
|
196
|
+
is_flag=True,
|
|
197
|
+
default=False,
|
|
198
|
+
help="Emit a single summary log entry when logger output is enabled",
|
|
199
|
+
)
|
|
200
|
+
no_auto_sync_option = click.option(
|
|
201
|
+
"--no-auto-sync",
|
|
202
|
+
is_flag=True,
|
|
203
|
+
default=False,
|
|
204
|
+
help="Disable automatic version reconciliation when migrations have been renamed",
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
def get_config_by_bind_key(ctx: "click.Context", bind_key: str | None) -> "AnyDatabaseConfig":
|
|
208
|
+
"""Get the SQLSpec config for the specified bind key.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
ctx: The click context.
|
|
212
|
+
bind_key: The bind key to get the config for.
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
The SQLSpec config for the specified bind key.
|
|
216
|
+
"""
|
|
217
|
+
configs = ctx.obj["configs"]
|
|
218
|
+
if bind_key is None:
|
|
219
|
+
config = configs[0]
|
|
220
|
+
else:
|
|
221
|
+
config = None
|
|
222
|
+
for cfg in configs:
|
|
223
|
+
config_name = cfg.bind_key
|
|
224
|
+
if config_name == bind_key:
|
|
225
|
+
config = cfg
|
|
226
|
+
break
|
|
227
|
+
|
|
228
|
+
if config is None:
|
|
229
|
+
console.print(f"[red]No config found for bind key: {bind_key}[/]")
|
|
230
|
+
sys.exit(1)
|
|
231
|
+
|
|
232
|
+
return cast("AnyDatabaseConfig", config)
|
|
233
|
+
|
|
234
|
+
def _adk_configs(ctx: "click.Context", bind_key: str | None) -> "list[AnyDatabaseConfig]":
|
|
235
|
+
if bind_key is not None:
|
|
236
|
+
return [get_config_by_bind_key(ctx, bind_key)]
|
|
237
|
+
|
|
238
|
+
configs = ctx.obj["configs"]
|
|
239
|
+
return [cfg for cfg in configs if "adk" in cfg.extension_config]
|
|
240
|
+
|
|
241
|
+
def _get_memory_store_class(
|
|
242
|
+
config: "AnyDatabaseConfig",
|
|
243
|
+
) -> "type[BaseAsyncADKMemoryStore[Any] | BaseSyncADKMemoryStore[Any]] | None":
|
|
244
|
+
from sqlspec.extensions.adk._config_utils import _adk_memory_migration_store_class
|
|
245
|
+
|
|
246
|
+
try:
|
|
247
|
+
return cast(
|
|
248
|
+
"type[BaseAsyncADKMemoryStore[Any] | BaseSyncADKMemoryStore[Any]] | None",
|
|
249
|
+
_adk_memory_migration_store_class(config),
|
|
250
|
+
)
|
|
251
|
+
except Exception:
|
|
252
|
+
return None
|
|
253
|
+
|
|
254
|
+
def _is_adk_memory_enabled(config: "AnyDatabaseConfig") -> bool:
|
|
255
|
+
adk_config = cast("dict[str, Any]", config.extension_config.get("adk", {}))
|
|
256
|
+
return bool(adk_config.get("enable_memory", True))
|
|
257
|
+
|
|
258
|
+
async def _close_cli_created_pool(config: Any, *, had_pool: bool) -> None:
|
|
259
|
+
"""Close an async pool initialized by a short-lived CLI event loop."""
|
|
260
|
+
if had_pool or getattr(config, "connection_instance", None) is None:
|
|
261
|
+
return
|
|
262
|
+
close_pool = getattr(config, "close_pool", None)
|
|
263
|
+
if close_pool is None:
|
|
264
|
+
return
|
|
265
|
+
maybe_awaitable = close_pool()
|
|
266
|
+
if inspect.isawaitable(maybe_awaitable):
|
|
267
|
+
await maybe_awaitable
|
|
268
|
+
|
|
269
|
+
async def _cleanup_memory_entries_async(store: "BaseAsyncADKMemoryStore[Any]", days: int) -> int:
|
|
270
|
+
had_pool = getattr(store.config, "connection_instance", None) is not None
|
|
271
|
+
try:
|
|
272
|
+
return await store.delete_entries_older_than(days)
|
|
273
|
+
finally:
|
|
274
|
+
await _close_cli_created_pool(store.config, had_pool=had_pool)
|
|
275
|
+
|
|
276
|
+
async def _verify_memory_table_async(
|
|
277
|
+
config: "AsyncDatabaseConfig[Any, Any, Any] | NoPoolAsyncConfig[Any, Any]", memory_table: str
|
|
278
|
+
) -> None:
|
|
279
|
+
had_pool = getattr(config, "connection_instance", None) is not None
|
|
280
|
+
try:
|
|
281
|
+
async with config.provide_session() as driver:
|
|
282
|
+
quoted_table = _quote_verified_table_identifier(
|
|
283
|
+
config, memory_table, _resolve_verify_dialect(config, driver)
|
|
284
|
+
)
|
|
285
|
+
await driver.execute(f"SELECT 1 FROM {quoted_table} WHERE 1 = 0")
|
|
286
|
+
finally:
|
|
287
|
+
await _close_cli_created_pool(config, had_pool=had_pool)
|
|
288
|
+
|
|
289
|
+
def get_configs_with_migrations(
|
|
290
|
+
ctx: "click.Context", enabled_only: bool = False
|
|
291
|
+
) -> "list[tuple[str, AnyDatabaseConfig]]":
|
|
292
|
+
"""Get all configurations that have migrations enabled.
|
|
293
|
+
|
|
294
|
+
Args:
|
|
295
|
+
ctx: The click context.
|
|
296
|
+
enabled_only: If True, only return configs with enabled=True.
|
|
297
|
+
|
|
298
|
+
Returns:
|
|
299
|
+
List of tuples (config_name, config) for configs with migrations enabled.
|
|
300
|
+
"""
|
|
301
|
+
configs: list[AnyDatabaseConfig] = ctx.obj["configs"]
|
|
302
|
+
migration_configs: list[tuple[str, AnyDatabaseConfig]] = []
|
|
303
|
+
|
|
304
|
+
for config in configs:
|
|
305
|
+
migration_config = config.migration_config
|
|
306
|
+
if migration_config:
|
|
307
|
+
enabled = migration_config.get("enabled", True)
|
|
308
|
+
if not enabled_only or enabled:
|
|
309
|
+
config_name = config.bind_key or str(type(config).__name__)
|
|
310
|
+
migration_configs.append((config_name, config))
|
|
311
|
+
|
|
312
|
+
return migration_configs
|
|
313
|
+
|
|
314
|
+
def filter_configs(
|
|
315
|
+
configs: "list[tuple[str, Any]]", include: "tuple[str, ...]", exclude: "tuple[str, ...]"
|
|
316
|
+
) -> "list[tuple[str, Any]]":
|
|
317
|
+
"""Filter configuration list based on include/exclude criteria.
|
|
318
|
+
|
|
319
|
+
Args:
|
|
320
|
+
configs: List of (config_name, config) tuples.
|
|
321
|
+
include: Config names to include (empty means include all).
|
|
322
|
+
exclude: Config names to exclude.
|
|
323
|
+
|
|
324
|
+
Returns:
|
|
325
|
+
Filtered list of configurations.
|
|
326
|
+
"""
|
|
327
|
+
filtered = configs
|
|
328
|
+
if include:
|
|
329
|
+
filtered = [(name, config) for name, config in filtered if name in include]
|
|
330
|
+
if exclude:
|
|
331
|
+
filtered = [(name, config) for name, config in filtered if name not in exclude]
|
|
332
|
+
return filtered
|
|
333
|
+
|
|
334
|
+
def _execute_for_config(
|
|
335
|
+
config: "AnyDatabaseConfig", sync_fn: "Callable[[], Any]", async_fn: "Callable[[], Any]"
|
|
336
|
+
) -> Any:
|
|
337
|
+
"""Execute a migration command with appropriate sync/async handling.
|
|
338
|
+
|
|
339
|
+
For sync configs, executes the sync function directly without an event loop.
|
|
340
|
+
For async configs, wraps the async function in run_() to execute with event loop.
|
|
341
|
+
|
|
342
|
+
Args:
|
|
343
|
+
config: The database configuration.
|
|
344
|
+
sync_fn: Function to call for sync configs (should call sync migration methods).
|
|
345
|
+
async_fn: Async function to call for async configs (should await async migration methods).
|
|
346
|
+
|
|
347
|
+
Returns:
|
|
348
|
+
The result of the executed function.
|
|
349
|
+
"""
|
|
350
|
+
if config.is_async:
|
|
351
|
+
had_pool = getattr(config, "connection_instance", None) is not None
|
|
352
|
+
|
|
353
|
+
async def _run_with_cleanup() -> Any:
|
|
354
|
+
try:
|
|
355
|
+
return await async_fn()
|
|
356
|
+
finally:
|
|
357
|
+
await _close_cli_created_pool(config, had_pool=had_pool)
|
|
358
|
+
|
|
359
|
+
return run_(_run_with_cleanup)()
|
|
360
|
+
return sync_fn()
|
|
361
|
+
|
|
362
|
+
def _create_cli_migration_commands(config: Any) -> "SyncMigrationCommands[Any] | AsyncMigrationCommands[Any]":
|
|
363
|
+
"""Create migration commands, reporting a rejected configuration as a CLI error.
|
|
364
|
+
|
|
365
|
+
Args:
|
|
366
|
+
config: The database configuration.
|
|
367
|
+
|
|
368
|
+
Returns:
|
|
369
|
+
Migration commands for the configuration.
|
|
370
|
+
|
|
371
|
+
Raises:
|
|
372
|
+
click.ClickException: When the configuration is rejected.
|
|
373
|
+
"""
|
|
374
|
+
try:
|
|
375
|
+
return migration_commands_module.create_migration_commands(config=config)
|
|
376
|
+
except SQLSpecError as exc:
|
|
377
|
+
raise click.ClickException(str(exc)) from exc
|
|
378
|
+
|
|
379
|
+
def _dispatch_migration_call(config: Any, method_name: str, **kwargs: Any) -> Any:
|
|
380
|
+
"""Run a migration command method with sync/async dispatch for one config.
|
|
381
|
+
|
|
382
|
+
SQLSpec errors become ``click.ClickException`` so the CLI exits non-zero with the message instead of a
|
|
383
|
+
traceback.
|
|
384
|
+
|
|
385
|
+
Args:
|
|
386
|
+
config: The database configuration.
|
|
387
|
+
method_name: Name of the migration command method to invoke.
|
|
388
|
+
**kwargs: Arguments forwarded to the command method.
|
|
389
|
+
|
|
390
|
+
Returns:
|
|
391
|
+
The result of the command method.
|
|
392
|
+
|
|
393
|
+
Raises:
|
|
394
|
+
click.ClickException: When the command raises a SQLSpec error.
|
|
395
|
+
"""
|
|
396
|
+
migration_commands = _create_cli_migration_commands(config)
|
|
397
|
+
method = getattr(migration_commands, method_name)
|
|
398
|
+
|
|
399
|
+
def _sync_call() -> Any:
|
|
400
|
+
return method(**kwargs)
|
|
401
|
+
|
|
402
|
+
async def _async_call() -> Any:
|
|
403
|
+
return await method(**kwargs)
|
|
404
|
+
|
|
405
|
+
try:
|
|
406
|
+
return _execute_for_config(config, _sync_call, _async_call)
|
|
407
|
+
except SQLSpecError as exc:
|
|
408
|
+
raise click.ClickException(str(exc)) from exc
|
|
409
|
+
|
|
410
|
+
async def _dispatch_migration_call_async(config: Any, method_name: str, **kwargs: Any) -> Any:
|
|
411
|
+
"""Await a migration command method inside an already-running event loop.
|
|
412
|
+
|
|
413
|
+
Args:
|
|
414
|
+
config: The async database configuration.
|
|
415
|
+
method_name: Name of the migration command method to invoke.
|
|
416
|
+
**kwargs: Arguments forwarded to the command method.
|
|
417
|
+
|
|
418
|
+
Returns:
|
|
419
|
+
The result of the command method.
|
|
420
|
+
|
|
421
|
+
Raises:
|
|
422
|
+
click.ClickException: When the command raises a SQLSpec error.
|
|
423
|
+
"""
|
|
424
|
+
migration_commands = _create_cli_migration_commands(config)
|
|
425
|
+
try:
|
|
426
|
+
return await getattr(migration_commands, method_name)(**kwargs)
|
|
427
|
+
except SQLSpecError as exc:
|
|
428
|
+
raise click.ClickException(str(exc)) from exc
|
|
429
|
+
|
|
430
|
+
def _partition_configs_by_async(
|
|
431
|
+
configs: "list[tuple[str, Any]]",
|
|
432
|
+
) -> "tuple[list[tuple[str, Any]], list[tuple[str, Any]]]":
|
|
433
|
+
"""Partition configs into sync and async groups.
|
|
434
|
+
|
|
435
|
+
Args:
|
|
436
|
+
configs: List of (config_name, config) tuples.
|
|
437
|
+
|
|
438
|
+
Returns:
|
|
439
|
+
Tuple of (sync_configs, async_configs).
|
|
440
|
+
"""
|
|
441
|
+
sync_configs = [(name, cfg) for name, cfg in configs if not cfg.is_async]
|
|
442
|
+
async_configs = [(name, cfg) for name, cfg in configs if cfg.is_async]
|
|
443
|
+
return sync_configs, async_configs
|
|
444
|
+
|
|
445
|
+
def _run_multi_config_operation(
|
|
446
|
+
configs_to_process: "list[tuple[str, Any]]",
|
|
447
|
+
*,
|
|
448
|
+
sync_apply: "Callable[[Any], None]",
|
|
449
|
+
async_apply: "Callable[[Any], Any]",
|
|
450
|
+
should_echo: "Callable[[Any], bool]",
|
|
451
|
+
progress_message: "Callable[[str], str] | None",
|
|
452
|
+
success_message: "Callable[[str], str] | None",
|
|
453
|
+
failure_message: "Callable[[str, Exception], str]",
|
|
454
|
+
output_console: "Console | None" = None,
|
|
455
|
+
) -> None:
|
|
456
|
+
"""Dispatch a migration operation across multiple configs.
|
|
457
|
+
|
|
458
|
+
Sync configs execute inline; async configs are batched into a single
|
|
459
|
+
``run_`` call so they share one event loop.
|
|
460
|
+
|
|
461
|
+
Args:
|
|
462
|
+
configs_to_process: List of (config_name, config) tuples.
|
|
463
|
+
sync_apply: Callable executing the operation for one sync config.
|
|
464
|
+
async_apply: Coroutine function executing the operation for one async config.
|
|
465
|
+
should_echo: Per-config predicate gating console output.
|
|
466
|
+
progress_message: Builds the per-config progress line, or None to skip.
|
|
467
|
+
success_message: Builds the per-config success line, or None to skip.
|
|
468
|
+
failure_message: Builds the per-config failure line.
|
|
469
|
+
output_console: Optional Console override for progress and error output.
|
|
470
|
+
"""
|
|
471
|
+
active_console = output_console if output_console is not None else console
|
|
472
|
+
sync_configs, async_configs = _partition_configs_by_async(configs_to_process)
|
|
473
|
+
errors: list[tuple[str, Exception]] = []
|
|
474
|
+
|
|
475
|
+
for config_name, config in sync_configs:
|
|
476
|
+
if progress_message is not None and should_echo(config):
|
|
477
|
+
active_console.print(progress_message(config_name))
|
|
478
|
+
try:
|
|
479
|
+
sync_apply(config)
|
|
480
|
+
if success_message is not None and should_echo(config):
|
|
481
|
+
active_console.print(success_message(config_name))
|
|
482
|
+
except Exception as e:
|
|
483
|
+
errors.append((config_name, e))
|
|
484
|
+
if should_echo(config):
|
|
485
|
+
active_console.print(failure_message(config_name, e))
|
|
486
|
+
|
|
487
|
+
if async_configs:
|
|
488
|
+
|
|
489
|
+
async def _run_async_configs() -> None:
|
|
490
|
+
for config_name, config in async_configs:
|
|
491
|
+
had_pool = getattr(config, "connection_instance", None) is not None
|
|
492
|
+
if progress_message is not None and should_echo(config):
|
|
493
|
+
active_console.print(progress_message(config_name))
|
|
494
|
+
try:
|
|
495
|
+
await async_apply(config)
|
|
496
|
+
if success_message is not None and should_echo(config):
|
|
497
|
+
active_console.print(success_message(config_name))
|
|
498
|
+
except Exception as e:
|
|
499
|
+
errors.append((config_name, e))
|
|
500
|
+
if should_echo(config):
|
|
501
|
+
active_console.print(failure_message(config_name, e))
|
|
502
|
+
finally:
|
|
503
|
+
await _close_cli_created_pool(config, had_pool=had_pool)
|
|
504
|
+
|
|
505
|
+
run_(_run_async_configs)()
|
|
506
|
+
|
|
507
|
+
if errors:
|
|
508
|
+
failed = ", ".join(name for name, _ in errors)
|
|
509
|
+
msg = f"Operation failed for config(s): {failed}"
|
|
510
|
+
raise click.ClickException(msg)
|
|
511
|
+
|
|
512
|
+
def _validate_cli_reconcilers(config: Any, op: Literal["upgrade", "downgrade"], target_revision: str) -> None:
|
|
513
|
+
"""Validate extension reconciler guards before running CLI operations."""
|
|
514
|
+
commands = _create_cli_migration_commands(config)
|
|
515
|
+
try:
|
|
516
|
+
commands.ensure_reconcilers_allow(op, target_revision)
|
|
517
|
+
except SQLSpecError as exc:
|
|
518
|
+
raise click.ClickException(str(exc)) from exc
|
|
519
|
+
|
|
520
|
+
def process_multiple_configs(
|
|
521
|
+
ctx: "click.Context",
|
|
522
|
+
bind_key: str | None,
|
|
523
|
+
include: "tuple[str, ...]",
|
|
524
|
+
exclude: "tuple[str, ...]",
|
|
525
|
+
dry_run: bool,
|
|
526
|
+
operation_name: str,
|
|
527
|
+
echo: bool = True,
|
|
528
|
+
output_console: "Console | None" = None,
|
|
529
|
+
before_dry_run: "Callable[[Any], None] | None" = None,
|
|
530
|
+
) -> "list[tuple[str, Any]] | None":
|
|
531
|
+
"""Process configuration selection for multi-config operations.
|
|
532
|
+
|
|
533
|
+
Requests targeting a single bind key or with only one available config run in single-config mode.
|
|
534
|
+
Enabled configs are used unless include/exclude widen the set, and dry runs simply list the configs that would execute.
|
|
535
|
+
|
|
536
|
+
Args:
|
|
537
|
+
ctx: Click context.
|
|
538
|
+
bind_key: Specific bind key to target.
|
|
539
|
+
include: Config names to include.
|
|
540
|
+
exclude: Config names to exclude.
|
|
541
|
+
dry_run: Whether this is a dry run.
|
|
542
|
+
operation_name: Name of the operation for display.
|
|
543
|
+
echo: Whether to echo output to the console.
|
|
544
|
+
output_console: Optional Console override for status messages.
|
|
545
|
+
before_dry_run: Optional preflight validator executed per selected config before printing dry-run output.
|
|
546
|
+
|
|
547
|
+
Returns:
|
|
548
|
+
List of (config_name, config) tuples to process, or None for single config mode.
|
|
549
|
+
"""
|
|
550
|
+
active_console = output_console if output_console is not None else console
|
|
551
|
+
if bind_key and not include and not exclude:
|
|
552
|
+
return None
|
|
553
|
+
|
|
554
|
+
enabled_only = not include and not exclude
|
|
555
|
+
migration_configs = get_configs_with_migrations(ctx, enabled_only=enabled_only)
|
|
556
|
+
|
|
557
|
+
if len(migration_configs) <= 1 and not include and not exclude:
|
|
558
|
+
return None
|
|
559
|
+
|
|
560
|
+
configs_to_process = filter_configs(migration_configs, include, exclude)
|
|
561
|
+
|
|
562
|
+
if not configs_to_process:
|
|
563
|
+
if echo:
|
|
564
|
+
active_console.print("[yellow]No configurations match the specified criteria.[/]")
|
|
565
|
+
return []
|
|
566
|
+
|
|
567
|
+
if dry_run:
|
|
568
|
+
if before_dry_run is not None:
|
|
569
|
+
for _, cfg in configs_to_process:
|
|
570
|
+
before_dry_run(cfg)
|
|
571
|
+
if echo:
|
|
572
|
+
active_console.print(
|
|
573
|
+
f"[blue]Dry run: Would {operation_name} {len(configs_to_process)} configuration(s)[/]"
|
|
574
|
+
)
|
|
575
|
+
for config_name, _ in configs_to_process:
|
|
576
|
+
active_console.print(f" • {config_name}")
|
|
577
|
+
return []
|
|
578
|
+
|
|
579
|
+
return configs_to_process
|
|
580
|
+
|
|
581
|
+
@database_group.command(name="show-current-revision", help="Shows the current revision for the database.")
|
|
582
|
+
@bind_key_option
|
|
583
|
+
@verbose_option
|
|
584
|
+
@include_option
|
|
585
|
+
@exclude_option
|
|
586
|
+
def show_database_revision( # pyright: ignore[reportUnusedFunction]
|
|
587
|
+
bind_key: str | None, verbose: bool, include: "tuple[str, ...]", exclude: "tuple[str, ...]"
|
|
588
|
+
) -> None:
|
|
589
|
+
"""Show current database revision.
|
|
590
|
+
|
|
591
|
+
Supports multi-config execution by partitioning selected configs into sync and async groups before dispatching them separately.
|
|
592
|
+
"""
|
|
593
|
+
ctx = _ensure_click_context()
|
|
594
|
+
|
|
595
|
+
def _show_for_config(config: Any) -> None:
|
|
596
|
+
"""Show current revision for a single config with sync/async dispatch."""
|
|
597
|
+
_dispatch_migration_call(config, "current", verbose=verbose)
|
|
598
|
+
|
|
599
|
+
configs_to_process = process_multiple_configs(
|
|
600
|
+
ctx, bind_key, include, exclude, dry_run=False, operation_name="show current revision"
|
|
601
|
+
)
|
|
602
|
+
|
|
603
|
+
async def _async_show(config: Any) -> None:
|
|
604
|
+
await _dispatch_migration_call_async(config, "current", verbose=verbose)
|
|
605
|
+
|
|
606
|
+
if configs_to_process is not None:
|
|
607
|
+
if not configs_to_process:
|
|
608
|
+
return
|
|
609
|
+
|
|
610
|
+
console.rule("[yellow]Listing current revisions for all configurations[/]", align="left")
|
|
611
|
+
|
|
612
|
+
_run_multi_config_operation(
|
|
613
|
+
configs_to_process,
|
|
614
|
+
sync_apply=_show_for_config,
|
|
615
|
+
async_apply=_async_show,
|
|
616
|
+
should_echo=lambda _config: True,
|
|
617
|
+
progress_message=lambda name: f"\n[blue]Configuration: {name}[/]",
|
|
618
|
+
success_message=None,
|
|
619
|
+
failure_message=lambda name, e: f"[red]✗ Failed to get current revision for {name}: {e}[/]",
|
|
620
|
+
)
|
|
621
|
+
else:
|
|
622
|
+
console.rule("[yellow]Listing current revision[/]", align="left")
|
|
623
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
624
|
+
_show_for_config(sqlspec_config)
|
|
625
|
+
|
|
626
|
+
def _create_echo_settings(
|
|
627
|
+
no_echo: bool, summary_only: bool, use_logger: bool
|
|
628
|
+
) -> tuple[bool | None, bool | None, bool, Callable[[Any], bool]]:
|
|
629
|
+
"""Create echo and summary settings with echo predicate closure.
|
|
630
|
+
|
|
631
|
+
Args:
|
|
632
|
+
no_echo: Flag indicating console output should be suppressed.
|
|
633
|
+
summary_only: Flag indicating only summary logs should be emitted.
|
|
634
|
+
use_logger: Flag indicating logger is used rather than console.
|
|
635
|
+
|
|
636
|
+
Returns:
|
|
637
|
+
Tuple of (echo_setting, summary_setting, echo_enabled, should_echo_predicate).
|
|
638
|
+
"""
|
|
639
|
+
effective_no_echo = no_echo or summary_only
|
|
640
|
+
echo_setting = False if effective_no_echo else None
|
|
641
|
+
summary_setting = True if summary_only else None
|
|
642
|
+
echo_enabled = not effective_no_echo and not use_logger
|
|
643
|
+
|
|
644
|
+
def _should_echo(config: Any) -> bool:
|
|
645
|
+
if not echo_enabled:
|
|
646
|
+
return False
|
|
647
|
+
migration_config = cast("dict[str, Any]", getattr(config, "migration_config", None)) or {}
|
|
648
|
+
return not bool(migration_config.get("use_logger", False))
|
|
649
|
+
|
|
650
|
+
return echo_setting, summary_setting, echo_enabled, _should_echo
|
|
651
|
+
|
|
652
|
+
@database_group.command(name="downgrade", help="Downgrade database to a specific revision.")
|
|
653
|
+
@bind_key_option
|
|
654
|
+
@no_prompt_option
|
|
655
|
+
@include_option
|
|
656
|
+
@exclude_option
|
|
657
|
+
@dry_run_option
|
|
658
|
+
@use_logger_option
|
|
659
|
+
@no_echo_option
|
|
660
|
+
@summary_only_option
|
|
661
|
+
@click.argument("revision", type=str, default="-1")
|
|
662
|
+
def downgrade_database( # pyright: ignore[reportUnusedFunction]
|
|
663
|
+
bind_key: str | None,
|
|
664
|
+
revision: str,
|
|
665
|
+
no_prompt: bool,
|
|
666
|
+
include: "tuple[str, ...]",
|
|
667
|
+
exclude: "tuple[str, ...]",
|
|
668
|
+
dry_run: bool,
|
|
669
|
+
use_logger: bool,
|
|
670
|
+
no_echo: bool,
|
|
671
|
+
summary_only: bool,
|
|
672
|
+
) -> None:
|
|
673
|
+
"""Downgrade the database to the latest revision."""
|
|
674
|
+
ctx = _ensure_click_context()
|
|
675
|
+
echo_setting, summary_setting, echo_enabled, _should_echo = _create_echo_settings(
|
|
676
|
+
no_echo, summary_only, use_logger
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
def _downgrade_for_config(config: Any) -> None:
|
|
680
|
+
"""Downgrade a single config with sync/async dispatch."""
|
|
681
|
+
_dispatch_migration_call(
|
|
682
|
+
config,
|
|
683
|
+
"downgrade",
|
|
684
|
+
revision=revision,
|
|
685
|
+
dry_run=dry_run,
|
|
686
|
+
use_logger=use_logger,
|
|
687
|
+
echo=echo_setting,
|
|
688
|
+
summary_only=summary_setting,
|
|
689
|
+
)
|
|
690
|
+
|
|
691
|
+
configs_to_process = process_multiple_configs(
|
|
692
|
+
ctx,
|
|
693
|
+
bind_key,
|
|
694
|
+
include,
|
|
695
|
+
exclude,
|
|
696
|
+
dry_run=dry_run,
|
|
697
|
+
operation_name=f"downgrade to {revision}",
|
|
698
|
+
echo=echo_enabled,
|
|
699
|
+
before_dry_run=lambda cfg: _validate_cli_reconcilers(cfg, "downgrade", revision),
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
async def _async_downgrade(config: Any) -> None:
|
|
703
|
+
await _dispatch_migration_call_async(
|
|
704
|
+
config,
|
|
705
|
+
"downgrade",
|
|
706
|
+
revision=revision,
|
|
707
|
+
dry_run=dry_run,
|
|
708
|
+
use_logger=use_logger,
|
|
709
|
+
echo=echo_setting,
|
|
710
|
+
summary_only=summary_setting,
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
if configs_to_process is not None:
|
|
714
|
+
if not configs_to_process:
|
|
715
|
+
return
|
|
716
|
+
|
|
717
|
+
if not no_prompt and not Confirm.ask(
|
|
718
|
+
f"[bold]Are you sure you want to downgrade {len(configs_to_process)} configuration(s) to revision {revision}?[/]"
|
|
719
|
+
):
|
|
720
|
+
if echo_enabled:
|
|
721
|
+
console.print("[yellow]Operation cancelled.[/]")
|
|
722
|
+
return
|
|
723
|
+
|
|
724
|
+
if echo_enabled:
|
|
725
|
+
console.rule("[yellow]Starting multi-configuration downgrade process[/]", align="left")
|
|
726
|
+
|
|
727
|
+
_run_multi_config_operation(
|
|
728
|
+
configs_to_process,
|
|
729
|
+
sync_apply=_downgrade_for_config,
|
|
730
|
+
async_apply=_async_downgrade,
|
|
731
|
+
should_echo=_should_echo,
|
|
732
|
+
progress_message=lambda name: f"[blue]Downgrading configuration: {name}[/]",
|
|
733
|
+
success_message=lambda name: f"[green]✓ Successfully downgraded: {name}[/]",
|
|
734
|
+
failure_message=lambda name, e: f"[red]✗ Failed to downgrade {name}: {e}[/]",
|
|
735
|
+
)
|
|
736
|
+
else:
|
|
737
|
+
if echo_enabled:
|
|
738
|
+
console.rule("[yellow]Starting database downgrade process[/]", align="left")
|
|
739
|
+
input_confirmed = (
|
|
740
|
+
True
|
|
741
|
+
if no_prompt
|
|
742
|
+
else Confirm.ask(f"Are you sure you want to downgrade the database to the `{revision}` revision?")
|
|
743
|
+
)
|
|
744
|
+
if input_confirmed:
|
|
745
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
746
|
+
_downgrade_for_config(sqlspec_config)
|
|
747
|
+
|
|
748
|
+
@database_group.command(name="upgrade", help="Upgrade database to a specific revision.")
|
|
749
|
+
@bind_key_option
|
|
750
|
+
@no_prompt_option
|
|
751
|
+
@include_option
|
|
752
|
+
@exclude_option
|
|
753
|
+
@dry_run_option
|
|
754
|
+
@use_logger_option
|
|
755
|
+
@no_echo_option
|
|
756
|
+
@summary_only_option
|
|
757
|
+
@no_auto_sync_option
|
|
758
|
+
@click.option(
|
|
759
|
+
"--allow-missing",
|
|
760
|
+
is_flag=True,
|
|
761
|
+
default=False,
|
|
762
|
+
help="Allow out-of-order migrations even when strict ordering is enabled.",
|
|
763
|
+
)
|
|
764
|
+
@click.argument("revision", type=str, default="head")
|
|
765
|
+
def upgrade_database( # pyright: ignore[reportUnusedFunction]
|
|
766
|
+
bind_key: str | None,
|
|
767
|
+
revision: str,
|
|
768
|
+
no_prompt: bool,
|
|
769
|
+
include: "tuple[str, ...]",
|
|
770
|
+
exclude: "tuple[str, ...]",
|
|
771
|
+
dry_run: bool,
|
|
772
|
+
use_logger: bool,
|
|
773
|
+
no_echo: bool,
|
|
774
|
+
summary_only: bool,
|
|
775
|
+
no_auto_sync: bool,
|
|
776
|
+
allow_missing: bool,
|
|
777
|
+
) -> None:
|
|
778
|
+
"""Upgrade the database to the latest revision."""
|
|
779
|
+
ctx = _ensure_click_context()
|
|
780
|
+
echo_setting, summary_setting, echo_enabled, _should_echo = _create_echo_settings(
|
|
781
|
+
no_echo, summary_only, use_logger
|
|
782
|
+
)
|
|
783
|
+
upgrade_kwargs: dict[str, Any] = {
|
|
784
|
+
"revision": revision,
|
|
785
|
+
"allow_missing": allow_missing,
|
|
786
|
+
"auto_sync": not no_auto_sync,
|
|
787
|
+
"dry_run": dry_run,
|
|
788
|
+
"use_logger": use_logger,
|
|
789
|
+
"echo": echo_setting,
|
|
790
|
+
"summary_only": summary_setting,
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
def _upgrade_for_config(config: Any) -> None:
|
|
794
|
+
"""Upgrade a single config with sync/async dispatch."""
|
|
795
|
+
_dispatch_migration_call(config, "upgrade", **upgrade_kwargs)
|
|
796
|
+
|
|
797
|
+
configs_to_process = process_multiple_configs(
|
|
798
|
+
ctx,
|
|
799
|
+
bind_key,
|
|
800
|
+
include,
|
|
801
|
+
exclude,
|
|
802
|
+
dry_run,
|
|
803
|
+
operation_name=f"upgrade to {revision}",
|
|
804
|
+
echo=echo_enabled,
|
|
805
|
+
before_dry_run=lambda cfg: _validate_cli_reconcilers(cfg, "upgrade", revision),
|
|
806
|
+
)
|
|
807
|
+
|
|
808
|
+
async def _async_upgrade(config: Any) -> None:
|
|
809
|
+
await _dispatch_migration_call_async(config, "upgrade", **upgrade_kwargs)
|
|
810
|
+
|
|
811
|
+
if configs_to_process is not None:
|
|
812
|
+
if not configs_to_process:
|
|
813
|
+
return
|
|
814
|
+
|
|
815
|
+
if not no_prompt and not Confirm.ask(
|
|
816
|
+
f"[bold]Are you sure you want to upgrade {len(configs_to_process)} configuration(s) to revision {revision}?[/]"
|
|
817
|
+
):
|
|
818
|
+
if echo_enabled:
|
|
819
|
+
console.print("[yellow]Operation cancelled.[/]")
|
|
820
|
+
return
|
|
821
|
+
|
|
822
|
+
if echo_enabled:
|
|
823
|
+
console.rule("[yellow]Starting multi-configuration upgrade process[/]", align="left")
|
|
824
|
+
|
|
825
|
+
_run_multi_config_operation(
|
|
826
|
+
configs_to_process,
|
|
827
|
+
sync_apply=_upgrade_for_config,
|
|
828
|
+
async_apply=_async_upgrade,
|
|
829
|
+
should_echo=_should_echo,
|
|
830
|
+
progress_message=lambda name: f"[blue]Upgrading configuration: {name}[/]",
|
|
831
|
+
success_message=lambda name: f"[green]✓ Successfully upgraded: {name}[/]",
|
|
832
|
+
failure_message=lambda name, e: f"[red]✗ Failed to upgrade {name}: {e}[/]",
|
|
833
|
+
)
|
|
834
|
+
else:
|
|
835
|
+
if echo_enabled:
|
|
836
|
+
console.rule("[yellow]Starting database upgrade process[/]", align="left")
|
|
837
|
+
input_confirmed = (
|
|
838
|
+
True
|
|
839
|
+
if no_prompt
|
|
840
|
+
else Confirm.ask(f"[bold]Are you sure you want migrate the database to the `{revision}` revision?[/]")
|
|
841
|
+
)
|
|
842
|
+
if input_confirmed:
|
|
843
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
844
|
+
_upgrade_for_config(sqlspec_config)
|
|
845
|
+
|
|
846
|
+
@database_group.command(help="Stamp the revision table with the given revision")
|
|
847
|
+
@click.argument("revision", type=str)
|
|
848
|
+
@bind_key_option
|
|
849
|
+
@no_prompt_option
|
|
850
|
+
def stamp(bind_key: str | None, revision: str, no_prompt: bool) -> None: # pyright: ignore[reportUnusedFunction]
|
|
851
|
+
"""Stamp the revision table with the given revision."""
|
|
852
|
+
ctx = _ensure_click_context()
|
|
853
|
+
input_confirmed = (
|
|
854
|
+
True
|
|
855
|
+
if no_prompt
|
|
856
|
+
else Confirm.ask(f"[bold]Are you sure you want to stamp the database to the `{revision}` revision?[/]")
|
|
857
|
+
)
|
|
858
|
+
if input_confirmed:
|
|
859
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
860
|
+
_dispatch_migration_call(sqlspec_config, "stamp", revision=revision)
|
|
861
|
+
|
|
862
|
+
@database_group.command(name="init", help="Initialize migrations for the project.")
|
|
863
|
+
@bind_key_option
|
|
864
|
+
@click.argument("directory", default=None, required=False)
|
|
865
|
+
@click.option("--package", is_flag=True, default=True, help="Create `__init__.py` for created folder")
|
|
866
|
+
@no_prompt_option
|
|
867
|
+
def init_sqlspec( # pyright: ignore[reportUnusedFunction]
|
|
868
|
+
bind_key: str | None, directory: str | None, package: bool, no_prompt: bool
|
|
869
|
+
) -> None:
|
|
870
|
+
"""Initialize the database migrations.
|
|
871
|
+
|
|
872
|
+
Sync configs are handled inline while async configs run via a single ``run_`` call so migrations stay in sync.
|
|
873
|
+
"""
|
|
874
|
+
ctx = _ensure_click_context()
|
|
875
|
+
|
|
876
|
+
console.rule("[yellow]Initializing database migrations.", align="left")
|
|
877
|
+
input_confirmed = (
|
|
878
|
+
True if no_prompt else Confirm.ask("[bold]Are you sure you want initialize migrations for the project?[/]")
|
|
879
|
+
)
|
|
880
|
+
if not input_confirmed:
|
|
881
|
+
return
|
|
882
|
+
|
|
883
|
+
configs = [get_config_by_bind_key(ctx, bind_key)] if bind_key is not None else ctx.obj["configs"]
|
|
884
|
+
|
|
885
|
+
sync_configs = [cfg for cfg in configs if not cfg.is_async]
|
|
886
|
+
async_configs = [cfg for cfg in configs if cfg.is_async]
|
|
887
|
+
|
|
888
|
+
for config in sync_configs:
|
|
889
|
+
migration_config_dict = config.migration_config or {}
|
|
890
|
+
target_directory = (
|
|
891
|
+
str(migration_config_dict.get("script_location", "migrations")) if directory is None else directory
|
|
892
|
+
)
|
|
893
|
+
migration_commands = _create_cli_migration_commands(config)
|
|
894
|
+
migration_commands.init(directory=target_directory, package=package)
|
|
895
|
+
|
|
896
|
+
if async_configs:
|
|
897
|
+
|
|
898
|
+
async def _init_async_configs() -> None:
|
|
899
|
+
for config in async_configs:
|
|
900
|
+
migration_config_dict = config.migration_config or {}
|
|
901
|
+
target_directory = (
|
|
902
|
+
str(migration_config_dict.get("script_location", "migrations"))
|
|
903
|
+
if directory is None
|
|
904
|
+
else directory
|
|
905
|
+
)
|
|
906
|
+
migration_commands: AsyncMigrationCommands[Any] = cast(
|
|
907
|
+
"AsyncMigrationCommands[Any]", _create_cli_migration_commands(config)
|
|
908
|
+
)
|
|
909
|
+
await migration_commands.init(directory=target_directory, package=package)
|
|
910
|
+
|
|
911
|
+
run_(_init_async_configs)()
|
|
912
|
+
|
|
913
|
+
@_safe_group_command(
|
|
914
|
+
database_group, name="create-migration", help="Create a new migration revision.", aliases=["make-migration"]
|
|
915
|
+
)
|
|
916
|
+
@bind_key_option
|
|
917
|
+
@click.option("-m", "--message", default=None, help="Revision message")
|
|
918
|
+
@click.option(
|
|
919
|
+
"--format",
|
|
920
|
+
"--file-type",
|
|
921
|
+
"file_format",
|
|
922
|
+
type=click.Choice(["sql", "py"]),
|
|
923
|
+
default=None,
|
|
924
|
+
help="File format for the generated migration (defaults to template profile)",
|
|
925
|
+
)
|
|
926
|
+
@click.option(
|
|
927
|
+
"--from-schema", is_flag=True, default=False, help="Bootstrap migration with current database schema DDL."
|
|
928
|
+
)
|
|
929
|
+
@click.option(
|
|
930
|
+
"--from-data",
|
|
931
|
+
default=None,
|
|
932
|
+
type=str,
|
|
933
|
+
help=(
|
|
934
|
+
"Bootstrap migration DDL from a data file or existing staging table. Values containing a path separator "
|
|
935
|
+
"or ending in a data suffix are files; other values are table names."
|
|
936
|
+
),
|
|
937
|
+
)
|
|
938
|
+
@click.option("--schema", default=None, type=str, help="Database schema name for --from-schema or --from-data.")
|
|
939
|
+
@click.option("--target-table", default=None, type=str, help="Target table name when bootstrapping from data.")
|
|
940
|
+
@no_prompt_option
|
|
941
|
+
def create_revision(
|
|
942
|
+
bind_key: str | None,
|
|
943
|
+
message: str | None,
|
|
944
|
+
file_format: str | None,
|
|
945
|
+
from_schema: bool,
|
|
946
|
+
from_data: str | None,
|
|
947
|
+
schema: str | None,
|
|
948
|
+
target_table: str | None,
|
|
949
|
+
no_prompt: bool,
|
|
950
|
+
) -> None:
|
|
951
|
+
"""Create a new database revision."""
|
|
952
|
+
ctx = _ensure_click_context()
|
|
953
|
+
|
|
954
|
+
if (
|
|
955
|
+
from_data is not None
|
|
956
|
+
and not target_table
|
|
957
|
+
and not migration_commands_module.MigrationCommandsCore._looks_like_data_path(from_data)
|
|
958
|
+
):
|
|
959
|
+
msg = "--target-table is required when --from-data specifies a source table name."
|
|
960
|
+
raise click.ClickException(msg)
|
|
961
|
+
|
|
962
|
+
console.rule("[yellow]Creating new migration revision[/]", align="left")
|
|
963
|
+
message_text = message
|
|
964
|
+
if message_text is None:
|
|
965
|
+
message_text = (
|
|
966
|
+
"new migration" if no_prompt else Prompt.ask("Please enter a message describing this revision")
|
|
967
|
+
)
|
|
968
|
+
|
|
969
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
970
|
+
_dispatch_migration_call(
|
|
971
|
+
sqlspec_config,
|
|
972
|
+
"revision",
|
|
973
|
+
message=message_text,
|
|
974
|
+
file_type=file_format,
|
|
975
|
+
from_schema=from_schema,
|
|
976
|
+
from_data=from_data,
|
|
977
|
+
schema=schema,
|
|
978
|
+
target_table=target_table,
|
|
979
|
+
)
|
|
980
|
+
|
|
981
|
+
@database_group.command(name="fix", help="Convert timestamp migrations to sequential format.")
|
|
982
|
+
@bind_key_option
|
|
983
|
+
@dry_run_option
|
|
984
|
+
@click.option("-y", "--yes", is_flag=True, help="Skip confirmation prompt")
|
|
985
|
+
@no_prompt_option
|
|
986
|
+
@include_option
|
|
987
|
+
@exclude_option
|
|
988
|
+
@use_logger_option
|
|
989
|
+
@no_echo_option
|
|
990
|
+
@click.option("--no-database", is_flag=True, help="Skip database record updates")
|
|
991
|
+
def fix_migrations(
|
|
992
|
+
bind_key: str | None,
|
|
993
|
+
dry_run: bool,
|
|
994
|
+
yes: bool,
|
|
995
|
+
no_prompt: bool,
|
|
996
|
+
include: "tuple[str, ...]",
|
|
997
|
+
exclude: "tuple[str, ...]",
|
|
998
|
+
use_logger: bool,
|
|
999
|
+
no_echo: bool,
|
|
1000
|
+
no_database: bool,
|
|
1001
|
+
) -> None:
|
|
1002
|
+
"""Convert timestamp migrations to sequential format."""
|
|
1003
|
+
ctx = _ensure_click_context()
|
|
1004
|
+
_, _, echo_enabled, _should_echo = _create_echo_settings(no_echo, False, use_logger)
|
|
1005
|
+
skip_prompt = yes or no_prompt
|
|
1006
|
+
|
|
1007
|
+
def _fix_for_config(config: Any) -> None:
|
|
1008
|
+
_dispatch_migration_call(config, "fix", dry_run=dry_run, update_database=not no_database, yes=skip_prompt)
|
|
1009
|
+
|
|
1010
|
+
async def _async_fix(config: Any) -> None:
|
|
1011
|
+
await _dispatch_migration_call_async(
|
|
1012
|
+
config, "fix", dry_run=dry_run, update_database=not no_database, yes=skip_prompt
|
|
1013
|
+
)
|
|
1014
|
+
|
|
1015
|
+
configs_to_process = process_multiple_configs(
|
|
1016
|
+
ctx, bind_key, include, exclude, dry_run=dry_run, operation_name="fix migrations", echo=echo_enabled
|
|
1017
|
+
)
|
|
1018
|
+
if configs_to_process is not None:
|
|
1019
|
+
if not configs_to_process:
|
|
1020
|
+
return
|
|
1021
|
+
if echo_enabled:
|
|
1022
|
+
console.rule("[yellow]Migration Fix Command[/]", align="left")
|
|
1023
|
+
_run_multi_config_operation(
|
|
1024
|
+
configs_to_process,
|
|
1025
|
+
sync_apply=_fix_for_config,
|
|
1026
|
+
async_apply=_async_fix,
|
|
1027
|
+
should_echo=_should_echo,
|
|
1028
|
+
progress_message=lambda name: f"[blue]Fixing configuration: {name}[/]",
|
|
1029
|
+
success_message=lambda name: f"[green]✓ Successfully fixed: {name}[/]",
|
|
1030
|
+
failure_message=lambda name, e: f"[red]✗ Failed to fix {name}: {e}[/]",
|
|
1031
|
+
)
|
|
1032
|
+
return
|
|
1033
|
+
|
|
1034
|
+
if echo_enabled:
|
|
1035
|
+
console.rule("[yellow]Migration Fix Command[/]", align="left")
|
|
1036
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
1037
|
+
_fix_for_config(sqlspec_config)
|
|
1038
|
+
|
|
1039
|
+
@database_group.command(name="squash")
|
|
1040
|
+
@bind_key_option
|
|
1041
|
+
@click.argument("version_range", required=False, default=None)
|
|
1042
|
+
@click.option("-m", "--message", required=False, default=None, help="Description for the squashed migration.")
|
|
1043
|
+
@dry_run_option
|
|
1044
|
+
@click.option("-y", "--yes", is_flag=True, help="Skip confirmation prompt")
|
|
1045
|
+
@no_prompt_option
|
|
1046
|
+
@include_option
|
|
1047
|
+
@exclude_option
|
|
1048
|
+
@use_logger_option
|
|
1049
|
+
@no_echo_option
|
|
1050
|
+
@click.option("--no-database", is_flag=True, help="Skip database record updates")
|
|
1051
|
+
@click.option("--allow-gaps", is_flag=True, help="Allow gaps in version sequence")
|
|
1052
|
+
@click.option(
|
|
1053
|
+
"--output-format",
|
|
1054
|
+
type=click.Choice(["sql", "py"], case_sensitive=False),
|
|
1055
|
+
default="sql",
|
|
1056
|
+
help="Output format for squashed migration (default: sql)",
|
|
1057
|
+
)
|
|
1058
|
+
@click.option(
|
|
1059
|
+
"--strategy",
|
|
1060
|
+
type=click.Choice(["ddl", "schema", "concat"], case_sensitive=False),
|
|
1061
|
+
default="concat",
|
|
1062
|
+
show_default=True,
|
|
1063
|
+
help=(
|
|
1064
|
+
"Squash strategy: keep every statement in order (concat), fold DDL into its final shape and refuse "
|
|
1065
|
+
"ranges that cannot be folded faithfully (ddl), or reflect the live database schema (schema)."
|
|
1066
|
+
),
|
|
1067
|
+
)
|
|
1068
|
+
@click.option(
|
|
1069
|
+
"--single-file/--split",
|
|
1070
|
+
"single_file",
|
|
1071
|
+
default=None,
|
|
1072
|
+
help=(
|
|
1073
|
+
"Force a single squashed file (--single-file) or split when file types or "
|
|
1074
|
+
"execution directives change (--split)."
|
|
1075
|
+
),
|
|
1076
|
+
)
|
|
1077
|
+
def squash_migrations(
|
|
1078
|
+
bind_key: str | None,
|
|
1079
|
+
version_range: str | None,
|
|
1080
|
+
message: str | None,
|
|
1081
|
+
dry_run: bool,
|
|
1082
|
+
yes: bool,
|
|
1083
|
+
no_prompt: bool,
|
|
1084
|
+
include: "tuple[str, ...]",
|
|
1085
|
+
exclude: "tuple[str, ...]",
|
|
1086
|
+
use_logger: bool,
|
|
1087
|
+
no_echo: bool,
|
|
1088
|
+
no_database: bool,
|
|
1089
|
+
allow_gaps: bool,
|
|
1090
|
+
output_format: str,
|
|
1091
|
+
strategy: str,
|
|
1092
|
+
single_file: bool | None,
|
|
1093
|
+
) -> None:
|
|
1094
|
+
"""Squash multiple sequential migrations into a single file.
|
|
1095
|
+
|
|
1096
|
+
VERSION_RANGE accepts START:END, START..END, or START-END, for example 1:7.
|
|
1097
|
+
"""
|
|
1098
|
+
ctx = _ensure_click_context()
|
|
1099
|
+
_, _, echo_enabled, _should_echo = _create_echo_settings(no_echo, False, use_logger)
|
|
1100
|
+
|
|
1101
|
+
start_version: str | None = None
|
|
1102
|
+
end_version: str | None = None
|
|
1103
|
+
if version_range is not None:
|
|
1104
|
+
try:
|
|
1105
|
+
start_version, end_version = parse_version_range(version_range)
|
|
1106
|
+
except ValueError as exc:
|
|
1107
|
+
console.print(f"[red]Error: {escape(str(exc))}[/]")
|
|
1108
|
+
raise SystemExit(1) from None
|
|
1109
|
+
|
|
1110
|
+
skip_prompt = yes or no_prompt
|
|
1111
|
+
squash_kwargs: dict[str, Any] = {
|
|
1112
|
+
"start_version": start_version,
|
|
1113
|
+
"end_version": end_version,
|
|
1114
|
+
"description": message,
|
|
1115
|
+
"dry_run": dry_run,
|
|
1116
|
+
"update_database": not no_database,
|
|
1117
|
+
"yes": skip_prompt,
|
|
1118
|
+
"allow_gaps": allow_gaps,
|
|
1119
|
+
"output_format": output_format.lower(),
|
|
1120
|
+
"strategy": strategy.lower(),
|
|
1121
|
+
}
|
|
1122
|
+
if single_file is not None:
|
|
1123
|
+
squash_kwargs["single_file"] = single_file
|
|
1124
|
+
|
|
1125
|
+
def _squash_for_config(config: Any) -> None:
|
|
1126
|
+
_dispatch_migration_call(config, "squash", **squash_kwargs)
|
|
1127
|
+
|
|
1128
|
+
async def _async_squash(config: Any) -> None:
|
|
1129
|
+
await _dispatch_migration_call_async(config, "squash", **squash_kwargs)
|
|
1130
|
+
|
|
1131
|
+
configs_to_process = process_multiple_configs(
|
|
1132
|
+
ctx, bind_key, include, exclude, dry_run=False, operation_name="squash migrations", echo=echo_enabled
|
|
1133
|
+
)
|
|
1134
|
+
if configs_to_process is not None:
|
|
1135
|
+
if not configs_to_process:
|
|
1136
|
+
return
|
|
1137
|
+
if echo_enabled:
|
|
1138
|
+
console.rule("[yellow]Migration Squash Command[/]", align="left")
|
|
1139
|
+
_run_multi_config_operation(
|
|
1140
|
+
configs_to_process,
|
|
1141
|
+
sync_apply=_squash_for_config,
|
|
1142
|
+
async_apply=_async_squash,
|
|
1143
|
+
should_echo=_should_echo,
|
|
1144
|
+
progress_message=lambda name: f"[blue]Squashing configuration: {name}[/]",
|
|
1145
|
+
success_message=lambda name: f"[green]✓ Successfully squashed: {name}[/]",
|
|
1146
|
+
failure_message=lambda name, e: f"[red]✗ Failed to squash {name}: {e}[/]",
|
|
1147
|
+
)
|
|
1148
|
+
return
|
|
1149
|
+
|
|
1150
|
+
if echo_enabled:
|
|
1151
|
+
console.rule("[yellow]Migration Squash Command[/]", align="left")
|
|
1152
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
1153
|
+
_squash_for_config(sqlspec_config)
|
|
1154
|
+
|
|
1155
|
+
@database_group.command(name="dump-schema", help="Export the current database schema DDL.")
|
|
1156
|
+
@click.option(
|
|
1157
|
+
"-o", "--output", type=click.Path(path_type=Path), default=None, help="Output file path for schema DDL."
|
|
1158
|
+
)
|
|
1159
|
+
@click.option("--schema", default=None, help="Database schema name to inspect.")
|
|
1160
|
+
@click.option(
|
|
1161
|
+
"--include-migrations-table",
|
|
1162
|
+
is_flag=True,
|
|
1163
|
+
default=False,
|
|
1164
|
+
help="Include the migration tracking table in the exported DDL.",
|
|
1165
|
+
)
|
|
1166
|
+
@click.option(
|
|
1167
|
+
"--prefer-native/--synthesize",
|
|
1168
|
+
default=True,
|
|
1169
|
+
help="Prefer engine-native catalog DDL when available or synthesize via SQLSpec builders.",
|
|
1170
|
+
)
|
|
1171
|
+
@click.option("--target-dialect", default=None, help="Target SQLGlot dialect for cross-dialect DDL transpilation.")
|
|
1172
|
+
@bind_key_option
|
|
1173
|
+
@include_option
|
|
1174
|
+
@exclude_option
|
|
1175
|
+
@no_echo_option
|
|
1176
|
+
def dump_schema_cmd(
|
|
1177
|
+
output: Path | None,
|
|
1178
|
+
schema: str | None,
|
|
1179
|
+
include_migrations_table: bool,
|
|
1180
|
+
prefer_native: bool,
|
|
1181
|
+
target_dialect: str | None,
|
|
1182
|
+
bind_key: str | None,
|
|
1183
|
+
include: "tuple[str, ...]",
|
|
1184
|
+
exclude: "tuple[str, ...]",
|
|
1185
|
+
no_echo: bool,
|
|
1186
|
+
) -> None:
|
|
1187
|
+
"""Export current database schema DDL.
|
|
1188
|
+
|
|
1189
|
+
Without ``--output`` the DDL is written to stdout byte-for-byte (no Rich markup or wrapping) so it can be
|
|
1190
|
+
redirected to a file.
|
|
1191
|
+
"""
|
|
1192
|
+
ctx = _ensure_click_context()
|
|
1193
|
+
echo_value = not no_echo
|
|
1194
|
+
|
|
1195
|
+
def _write_ddl(rendered: str) -> None:
|
|
1196
|
+
if output is None and echo_value:
|
|
1197
|
+
sys.stdout.write(rendered)
|
|
1198
|
+
sys.stdout.flush()
|
|
1199
|
+
|
|
1200
|
+
def _dump_for_config(config: Any) -> None:
|
|
1201
|
+
_write_ddl(
|
|
1202
|
+
_dispatch_migration_call(
|
|
1203
|
+
config,
|
|
1204
|
+
"dump_schema",
|
|
1205
|
+
output_path=output,
|
|
1206
|
+
schema=schema,
|
|
1207
|
+
include_migrations_table=include_migrations_table,
|
|
1208
|
+
prefer_native=prefer_native,
|
|
1209
|
+
target_dialect=target_dialect,
|
|
1210
|
+
echo=echo_value,
|
|
1211
|
+
)
|
|
1212
|
+
)
|
|
1213
|
+
|
|
1214
|
+
async def _async_dump(config: Any) -> None:
|
|
1215
|
+
_write_ddl(
|
|
1216
|
+
await _dispatch_migration_call_async(
|
|
1217
|
+
config,
|
|
1218
|
+
"dump_schema",
|
|
1219
|
+
output_path=output,
|
|
1220
|
+
schema=schema,
|
|
1221
|
+
include_migrations_table=include_migrations_table,
|
|
1222
|
+
prefer_native=prefer_native,
|
|
1223
|
+
target_dialect=target_dialect,
|
|
1224
|
+
echo=echo_value,
|
|
1225
|
+
)
|
|
1226
|
+
)
|
|
1227
|
+
|
|
1228
|
+
stderr_console = Console(stderr=True)
|
|
1229
|
+
configs_to_process = process_multiple_configs(
|
|
1230
|
+
ctx,
|
|
1231
|
+
bind_key,
|
|
1232
|
+
include,
|
|
1233
|
+
exclude,
|
|
1234
|
+
dry_run=False,
|
|
1235
|
+
operation_name="dump schema",
|
|
1236
|
+
echo=echo_value,
|
|
1237
|
+
output_console=stderr_console,
|
|
1238
|
+
)
|
|
1239
|
+
if configs_to_process is not None:
|
|
1240
|
+
if not configs_to_process:
|
|
1241
|
+
return
|
|
1242
|
+
if output is not None:
|
|
1243
|
+
msg = (
|
|
1244
|
+
"Cannot use a single --output file when dumping schema across multiple configurations; "
|
|
1245
|
+
"specify --bind-key or omit --output."
|
|
1246
|
+
)
|
|
1247
|
+
raise click.ClickException(msg)
|
|
1248
|
+
_run_multi_config_operation(
|
|
1249
|
+
configs_to_process,
|
|
1250
|
+
sync_apply=_dump_for_config,
|
|
1251
|
+
async_apply=_async_dump,
|
|
1252
|
+
should_echo=lambda _cfg: echo_value,
|
|
1253
|
+
progress_message=lambda name: f"[blue]Dumping schema for configuration: {name}[/]",
|
|
1254
|
+
success_message=None,
|
|
1255
|
+
failure_message=lambda name, e: f"[red]✗ Failed to dump schema for {name}: {e}[/]",
|
|
1256
|
+
output_console=stderr_console,
|
|
1257
|
+
)
|
|
1258
|
+
return
|
|
1259
|
+
|
|
1260
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
1261
|
+
_dump_for_config(sqlspec_config)
|
|
1262
|
+
|
|
1263
|
+
@database_group.command(
|
|
1264
|
+
name="verify", help="Verify database migration tracking records against migration files on disk."
|
|
1265
|
+
)
|
|
1266
|
+
@click.option(
|
|
1267
|
+
"--strict",
|
|
1268
|
+
is_flag=True,
|
|
1269
|
+
default=False,
|
|
1270
|
+
help="Exit non-zero on checksum mismatch, orphaned applied migration, or partially applied squash.",
|
|
1271
|
+
)
|
|
1272
|
+
@click.option("--fail-on-pending", is_flag=True, default=False, help="Exit non-zero when migrations are pending.")
|
|
1273
|
+
@bind_key_option
|
|
1274
|
+
@include_option
|
|
1275
|
+
@exclude_option
|
|
1276
|
+
@use_logger_option
|
|
1277
|
+
@no_echo_option
|
|
1278
|
+
def verify_migrations_cmd(
|
|
1279
|
+
strict: bool,
|
|
1280
|
+
fail_on_pending: bool,
|
|
1281
|
+
bind_key: str | None,
|
|
1282
|
+
include: "tuple[str, ...]",
|
|
1283
|
+
exclude: "tuple[str, ...]",
|
|
1284
|
+
use_logger: bool,
|
|
1285
|
+
no_echo: bool,
|
|
1286
|
+
) -> None:
|
|
1287
|
+
"""Verify database migration tracking records against migration files on disk.
|
|
1288
|
+
|
|
1289
|
+
Verification is read-only and never creates the tracking table.
|
|
1290
|
+
"""
|
|
1291
|
+
ctx = _ensure_click_context()
|
|
1292
|
+
echo_setting, _, echo_enabled, _should_echo = _create_echo_settings(no_echo, False, use_logger)
|
|
1293
|
+
verify_kwargs: dict[str, Any] = {
|
|
1294
|
+
"strict": strict,
|
|
1295
|
+
"fail_on_pending": fail_on_pending,
|
|
1296
|
+
"use_logger": use_logger,
|
|
1297
|
+
"echo": echo_setting,
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
def _verify_for_config(config: Any) -> None:
|
|
1301
|
+
_dispatch_migration_call(config, "verify", **verify_kwargs)
|
|
1302
|
+
|
|
1303
|
+
async def _async_verify(config: Any) -> None:
|
|
1304
|
+
await _dispatch_migration_call_async(config, "verify", **verify_kwargs)
|
|
1305
|
+
|
|
1306
|
+
configs_to_process = process_multiple_configs(
|
|
1307
|
+
ctx, bind_key, include, exclude, dry_run=False, operation_name="verify migrations", echo=echo_enabled
|
|
1308
|
+
)
|
|
1309
|
+
if configs_to_process is not None:
|
|
1310
|
+
if not configs_to_process:
|
|
1311
|
+
return
|
|
1312
|
+
_run_multi_config_operation(
|
|
1313
|
+
configs_to_process,
|
|
1314
|
+
sync_apply=_verify_for_config,
|
|
1315
|
+
async_apply=_async_verify,
|
|
1316
|
+
should_echo=_should_echo,
|
|
1317
|
+
progress_message=lambda name: f"[blue]Verifying configuration: {name}[/]",
|
|
1318
|
+
success_message=None,
|
|
1319
|
+
failure_message=lambda name, e: f"[red]✗ Verification failed for {name}: {e}[/]",
|
|
1320
|
+
)
|
|
1321
|
+
return
|
|
1322
|
+
|
|
1323
|
+
sqlspec_config = get_config_by_bind_key(ctx, bind_key)
|
|
1324
|
+
_verify_for_config(sqlspec_config)
|
|
1325
|
+
|
|
1326
|
+
@database_group.command(name="show-config", help="Show all configurations with migrations enabled.")
|
|
1327
|
+
@bind_key_option
|
|
1328
|
+
def show_config(bind_key: str | None = None) -> None: # pyright: ignore[reportUnusedFunction]
|
|
1329
|
+
"""Show and display all configurations with migrations enabled.
|
|
1330
|
+
|
|
1331
|
+
Providing a bind key validates that config while still iterating the original config list to remain compatible with existing callers.
|
|
1332
|
+
"""
|
|
1333
|
+
ctx = _ensure_click_context()
|
|
1334
|
+
|
|
1335
|
+
if bind_key is not None:
|
|
1336
|
+
get_config_by_bind_key(ctx, bind_key)
|
|
1337
|
+
all_configs: list[AnyDatabaseConfig] = ctx.obj["configs"]
|
|
1338
|
+
migration_configs: list[tuple[str, AnyDatabaseConfig]] = []
|
|
1339
|
+
for cfg in all_configs:
|
|
1340
|
+
config_name = cfg.bind_key
|
|
1341
|
+
if config_name == bind_key and cfg.migration_config:
|
|
1342
|
+
migration_configs.append((config_name, cfg)) # pyright: ignore[reportArgumentType]
|
|
1343
|
+
else:
|
|
1344
|
+
migration_configs = get_configs_with_migrations(ctx)
|
|
1345
|
+
|
|
1346
|
+
if not migration_configs:
|
|
1347
|
+
console.print("[yellow]No configurations with migrations detected.[/]")
|
|
1348
|
+
return
|
|
1349
|
+
|
|
1350
|
+
table = Table(title="Migration Configurations")
|
|
1351
|
+
table.add_column("Configuration Name", style="cyan")
|
|
1352
|
+
table.add_column("Migration Path", style="blue")
|
|
1353
|
+
table.add_column("Status", style="green")
|
|
1354
|
+
|
|
1355
|
+
for config_name, config in migration_configs:
|
|
1356
|
+
migration_config_dict = config.migration_config or {}
|
|
1357
|
+
script_location = migration_config_dict.get("script_location", "migrations")
|
|
1358
|
+
table.add_row(config_name, str(script_location), "Migration Enabled")
|
|
1359
|
+
|
|
1360
|
+
console.print(table)
|
|
1361
|
+
console.print(f"[blue]Found {len(migration_configs)} configuration(s) with migrations enabled.[/]")
|
|
1362
|
+
|
|
1363
|
+
@database_group.group(name="adk", help="ADK extension commands")
|
|
1364
|
+
def adk_group() -> None: # pyright: ignore[reportUnusedFunction]
|
|
1365
|
+
"""ADK extension commands."""
|
|
1366
|
+
|
|
1367
|
+
@adk_group.group(name="memory", help="ADK memory store commands")
|
|
1368
|
+
def adk_memory_group() -> None: # pyright: ignore[reportUnusedFunction]
|
|
1369
|
+
"""ADK memory store commands."""
|
|
1370
|
+
|
|
1371
|
+
@adk_memory_group.command(name="cleanup", help="Delete memory entries older than N days")
|
|
1372
|
+
@bind_key_option
|
|
1373
|
+
@click.option("--days", type=int, required=True, help="Delete entries older than this many days")
|
|
1374
|
+
def cleanup_memory(bind_key: str | None, days: int) -> None: # pyright: ignore[reportUnusedFunction]
|
|
1375
|
+
"""Cleanup memory entries older than N days."""
|
|
1376
|
+
ctx = _ensure_click_context()
|
|
1377
|
+
configs = _adk_configs(ctx, bind_key)
|
|
1378
|
+
|
|
1379
|
+
if not configs:
|
|
1380
|
+
console.print("[yellow]No ADK configurations found.[/]")
|
|
1381
|
+
return
|
|
1382
|
+
|
|
1383
|
+
for cfg in configs:
|
|
1384
|
+
config_name = cfg.bind_key or "default"
|
|
1385
|
+
if not _is_adk_memory_enabled(cfg):
|
|
1386
|
+
console.print(f"[yellow]Memory disabled for {config_name}; skipping.[/]")
|
|
1387
|
+
continue
|
|
1388
|
+
|
|
1389
|
+
store_class = _get_memory_store_class(cfg)
|
|
1390
|
+
if store_class is None:
|
|
1391
|
+
console.print(f"[yellow]No memory store found for {config_name}; skipping.[/]")
|
|
1392
|
+
continue
|
|
1393
|
+
|
|
1394
|
+
if isinstance(cfg, (AsyncDatabaseConfig, NoPoolAsyncConfig)):
|
|
1395
|
+
async_store = cast("BaseAsyncADKMemoryStore[Any]", store_class(cfg))
|
|
1396
|
+
deleted = run_(_cleanup_memory_entries_async)(async_store, days)
|
|
1397
|
+
console.print(f"[green]✓[/] {config_name}: deleted {deleted} memory entries older than {days} days")
|
|
1398
|
+
continue
|
|
1399
|
+
sync_store = cast("BaseSyncADKMemoryStore[Any]", store_class(cfg))
|
|
1400
|
+
deleted = sync_store.delete_entries_older_than(days)
|
|
1401
|
+
console.print(f"[green]✓[/] {config_name}: deleted {deleted} memory entries older than {days} days")
|
|
1402
|
+
|
|
1403
|
+
@adk_memory_group.command(name="verify", help="Verify memory table exists and is reachable")
|
|
1404
|
+
@bind_key_option
|
|
1405
|
+
def verify_memory(bind_key: str | None) -> None: # pyright: ignore[reportUnusedFunction]
|
|
1406
|
+
"""Verify memory tables are reachable for configured adapters."""
|
|
1407
|
+
ctx = _ensure_click_context()
|
|
1408
|
+
configs = _adk_configs(ctx, bind_key)
|
|
1409
|
+
|
|
1410
|
+
if not configs:
|
|
1411
|
+
console.print("[yellow]No ADK configurations found.[/]")
|
|
1412
|
+
return
|
|
1413
|
+
|
|
1414
|
+
failed_configs: list[str] = []
|
|
1415
|
+
for cfg in configs:
|
|
1416
|
+
config_name = cfg.bind_key or "default"
|
|
1417
|
+
if not _is_adk_memory_enabled(cfg):
|
|
1418
|
+
console.print(f"[yellow]Memory disabled for {config_name}; skipping.[/]")
|
|
1419
|
+
continue
|
|
1420
|
+
|
|
1421
|
+
store_class = _get_memory_store_class(cfg)
|
|
1422
|
+
if store_class is None:
|
|
1423
|
+
console.print(f"[yellow]No memory store found for {config_name}; skipping.[/]")
|
|
1424
|
+
continue
|
|
1425
|
+
|
|
1426
|
+
try:
|
|
1427
|
+
if isinstance(cfg, (AsyncDatabaseConfig, NoPoolAsyncConfig)):
|
|
1428
|
+
async_cfg: AsyncDatabaseConfig[Any, Any, Any] | NoPoolAsyncConfig[Any, Any] = cfg
|
|
1429
|
+
async_store = cast("BaseAsyncADKMemoryStore[Any]", store_class(async_cfg))
|
|
1430
|
+
run_(_verify_memory_table_async)(async_cfg, async_store.memory_table)
|
|
1431
|
+
console.print(f"[green]✓[/] {config_name}: memory table reachable")
|
|
1432
|
+
continue
|
|
1433
|
+
sync_store = cast("BaseSyncADKMemoryStore[Any]", store_class(cfg))
|
|
1434
|
+
with cfg.provide_session() as driver:
|
|
1435
|
+
quoted_table = _quote_verified_table_identifier(
|
|
1436
|
+
cfg, sync_store.memory_table, _resolve_verify_dialect(cfg, driver)
|
|
1437
|
+
)
|
|
1438
|
+
driver.execute(f"SELECT 1 FROM {quoted_table} WHERE 1 = 0")
|
|
1439
|
+
console.print(f"[green]✓[/] {config_name}: memory table reachable")
|
|
1440
|
+
except Exception as exc:
|
|
1441
|
+
console.print(f"[red]✗[/] {config_name}: {exc}")
|
|
1442
|
+
failed_configs.append(config_name)
|
|
1443
|
+
|
|
1444
|
+
if failed_configs:
|
|
1445
|
+
msg = f"Memory table verification failed for: {', '.join(failed_configs)}"
|
|
1446
|
+
raise click.ClickException(msg)
|
|
1447
|
+
|
|
1448
|
+
return database_group
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
def __getattr__(name: str) -> Any:
|
|
1452
|
+
"""Lazily construct the root Click command group for CLI documentation tools."""
|
|
1453
|
+
if name == "cli":
|
|
1454
|
+
return add_migration_commands()
|
|
1455
|
+
msg = f"module {__name__!r} has no attribute {name!r}"
|
|
1456
|
+
raise AttributeError(msg)
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
_BACKTICK_QUOTE_DIALECTS: frozenset[str] = frozenset({"mysql", "mariadb", "bigquery", "spanner"})
|
|
1460
|
+
_BRACKET_QUOTE_DIALECTS: frozenset[str] = frozenset({"tsql", "mssql", "sybase"})
|
|
1461
|
+
_UPPERCASE_QUOTE_DIALECTS: frozenset[str] = frozenset({"oracle", "db2", "snowflake", "teradata", "vantage"})
|
|
1462
|
+
_LOWERCASE_QUOTE_DIALECTS: frozenset[str] = frozenset({
|
|
1463
|
+
"postgres",
|
|
1464
|
+
"postgresql",
|
|
1465
|
+
"pgvector",
|
|
1466
|
+
"paradedb",
|
|
1467
|
+
"pg_textsearch",
|
|
1468
|
+
"pgtextsearch",
|
|
1469
|
+
"cockroach",
|
|
1470
|
+
"cockroachdb",
|
|
1471
|
+
"spangres",
|
|
1472
|
+
})
|
|
1473
|
+
_DBO_DEFAULT_SCHEMA_ADAPTERS: frozenset[str] = frozenset({"mssql_python", "pymssql", "sybase"})
|
|
1474
|
+
_TSQL_DIALECTS: frozenset[str] = frozenset({"tsql", "mssql"})
|
|
1475
|
+
_MIN_QUOTED_TOKEN_LEN: int = 2
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
def _normalize_verify_dialect(dialect: Any) -> str | None:
|
|
1479
|
+
"""Normalize a string or SQLGlot Dialect class/instance to a lowercase dialect name."""
|
|
1480
|
+
from sqlglot.dialects.dialect import Dialect
|
|
1481
|
+
|
|
1482
|
+
if isinstance(dialect, str):
|
|
1483
|
+
cleaned = dialect.strip().lower()
|
|
1484
|
+
return cleaned or None
|
|
1485
|
+
if isinstance(dialect, type) and issubclass(dialect, Dialect):
|
|
1486
|
+
return dialect.__name__.lower()
|
|
1487
|
+
if isinstance(dialect, Dialect):
|
|
1488
|
+
return type(dialect).__name__.lower()
|
|
1489
|
+
return None
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
def _resolve_verify_dialect(config: Any, driver: Any = None) -> str | None:
|
|
1493
|
+
"""Resolve the active SQL dialect for ADK table verification."""
|
|
1494
|
+
from sqlspec.migrations.context import MigrationContext
|
|
1495
|
+
|
|
1496
|
+
driver_dialect_name = getattr(driver, "_dialect_name", None)
|
|
1497
|
+
if isinstance(driver_dialect_name, str):
|
|
1498
|
+
cleaned_name = driver_dialect_name.strip().lower()
|
|
1499
|
+
if cleaned_name:
|
|
1500
|
+
return cleaned_name
|
|
1501
|
+
|
|
1502
|
+
stmt_dialect = _normalize_verify_dialect(getattr(getattr(driver, "statement_config", None), "dialect", None))
|
|
1503
|
+
if stmt_dialect is not None:
|
|
1504
|
+
return stmt_dialect
|
|
1505
|
+
|
|
1506
|
+
context_dialect = _normalize_verify_dialect(MigrationContext.from_config(config).dialect)
|
|
1507
|
+
if context_dialect is not None:
|
|
1508
|
+
return context_dialect
|
|
1509
|
+
|
|
1510
|
+
return _normalize_verify_dialect(getattr(driver, "dialect", None))
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
def _split_identifier_tokens(identifier: str) -> list[tuple[str, bool]]:
|
|
1514
|
+
"""Split a qualified SQL identifier into ``(unquoted_part, was_quoted)`` tokens."""
|
|
1515
|
+
cleaned = identifier.strip()
|
|
1516
|
+
if not cleaned:
|
|
1517
|
+
return []
|
|
1518
|
+
|
|
1519
|
+
raw_parts: list[str] = []
|
|
1520
|
+
chars: list[str] = []
|
|
1521
|
+
quote_end = ""
|
|
1522
|
+
index = 0
|
|
1523
|
+
length = len(cleaned)
|
|
1524
|
+
while index < length:
|
|
1525
|
+
char = cleaned[index]
|
|
1526
|
+
if quote_end:
|
|
1527
|
+
chars.append(char)
|
|
1528
|
+
if char == quote_end:
|
|
1529
|
+
if index + 1 < length and cleaned[index + 1] == quote_end:
|
|
1530
|
+
chars.append(cleaned[index + 1])
|
|
1531
|
+
index += 2
|
|
1532
|
+
continue
|
|
1533
|
+
quote_end = ""
|
|
1534
|
+
index += 1
|
|
1535
|
+
continue
|
|
1536
|
+
if char == "[":
|
|
1537
|
+
quote_end = "]"
|
|
1538
|
+
chars.append(char)
|
|
1539
|
+
index += 1
|
|
1540
|
+
continue
|
|
1541
|
+
if char in {'"', "`"}:
|
|
1542
|
+
quote_end = char
|
|
1543
|
+
chars.append(char)
|
|
1544
|
+
index += 1
|
|
1545
|
+
continue
|
|
1546
|
+
if char == ".":
|
|
1547
|
+
part = "".join(chars).strip()
|
|
1548
|
+
if part:
|
|
1549
|
+
raw_parts.append(part)
|
|
1550
|
+
chars.clear()
|
|
1551
|
+
index += 1
|
|
1552
|
+
continue
|
|
1553
|
+
chars.append(char)
|
|
1554
|
+
index += 1
|
|
1555
|
+
|
|
1556
|
+
tail = "".join(chars).strip()
|
|
1557
|
+
if tail:
|
|
1558
|
+
raw_parts.append(tail)
|
|
1559
|
+
|
|
1560
|
+
tokens: list[tuple[str, bool]] = []
|
|
1561
|
+
for raw in raw_parts:
|
|
1562
|
+
if len(raw) >= _MIN_QUOTED_TOKEN_LEN and raw[0] == "[" and raw[-1] == "]":
|
|
1563
|
+
tokens.append((raw[1:-1].replace("]]", "]"), True))
|
|
1564
|
+
elif len(raw) >= _MIN_QUOTED_TOKEN_LEN and raw[0] == '"' and raw[-1] == '"':
|
|
1565
|
+
tokens.append((raw[1:-1].replace('""', '"'), True))
|
|
1566
|
+
elif len(raw) >= _MIN_QUOTED_TOKEN_LEN and raw[0] == "`" and raw[-1] == "`":
|
|
1567
|
+
tokens.append((raw[1:-1].replace("``", "`"), True))
|
|
1568
|
+
else:
|
|
1569
|
+
tokens.append((raw, False))
|
|
1570
|
+
return tokens
|
|
1571
|
+
|
|
1572
|
+
|
|
1573
|
+
def _quote_identifier_token(part: str, *, was_quoted: bool, normalized_dialect: str) -> str:
|
|
1574
|
+
"""Quote a single identifier token using dialect-specific delimiters and case folding."""
|
|
1575
|
+
if normalized_dialect in _BACKTICK_QUOTE_DIALECTS:
|
|
1576
|
+
return f"`{part.replace('`', '``')}`"
|
|
1577
|
+
if normalized_dialect in _BRACKET_QUOTE_DIALECTS:
|
|
1578
|
+
return f"[{part.replace(']', ']]')}]"
|
|
1579
|
+
if normalized_dialect in _UPPERCASE_QUOTE_DIALECTS:
|
|
1580
|
+
folded = part if was_quoted else part.upper()
|
|
1581
|
+
return f'"{folded.replace(chr(34), chr(34) * 2)}"'
|
|
1582
|
+
if normalized_dialect in _LOWERCASE_QUOTE_DIALECTS:
|
|
1583
|
+
folded = part if was_quoted else part.lower()
|
|
1584
|
+
return f'"{folded.replace(chr(34), chr(34) * 2)}"'
|
|
1585
|
+
return f'"{part.replace(chr(34), chr(34) * 2)}"'
|
|
1586
|
+
|
|
1587
|
+
|
|
1588
|
+
def _quote_identifier_for_dialect(identifier: str, dialect: str | None) -> str:
|
|
1589
|
+
"""Quote a single or qualified SQL identifier for the target dialect."""
|
|
1590
|
+
normalized = (dialect or "").strip().lower()
|
|
1591
|
+
tokens = _split_identifier_tokens(identifier)
|
|
1592
|
+
if not tokens:
|
|
1593
|
+
return _quote_identifier_token(identifier, was_quoted=False, normalized_dialect=normalized)
|
|
1594
|
+
return ".".join(
|
|
1595
|
+
_quote_identifier_token(part, was_quoted=was_quoted, normalized_dialect=normalized)
|
|
1596
|
+
for part, was_quoted in tokens
|
|
1597
|
+
)
|
|
1598
|
+
|
|
1599
|
+
|
|
1600
|
+
def _quote_verified_table_identifier(config: Any, memory_table: str, dialect: str | None) -> str:
|
|
1601
|
+
"""Quote and default-schema qualify an ADK memory table identifier for verification."""
|
|
1602
|
+
normalized = (dialect or "").strip().lower()
|
|
1603
|
+
tokens = _split_identifier_tokens(memory_table)
|
|
1604
|
+
if len(tokens) == 1:
|
|
1605
|
+
adapter_name = resolve_adapter_name(config)
|
|
1606
|
+
cleaned_table = memory_table.strip()
|
|
1607
|
+
if adapter_name in _DBO_DEFAULT_SCHEMA_ADAPTERS or (
|
|
1608
|
+
adapter_name == "arrow_odbc" and normalized in _TSQL_DIALECTS
|
|
1609
|
+
):
|
|
1610
|
+
return _quote_identifier_for_dialect(f"[dbo].{cleaned_table}", dialect)
|
|
1611
|
+
if adapter_name == "sqlanywhere":
|
|
1612
|
+
return _quote_identifier_for_dialect(f'"DBA".{cleaned_table}', dialect)
|
|
1613
|
+
return _quote_identifier_for_dialect(memory_table, dialect)
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
class _SQLSpecGroup(click.RichGroup):
|
|
1617
|
+
"""Click group that records raw CLI arguments prior to subcommand resolution."""
|
|
1618
|
+
|
|
1619
|
+
def parse_args(self, ctx: "click.Context", args: "list[str]") -> "list[str]":
|
|
1620
|
+
ctx.ensure_object(dict)
|
|
1621
|
+
raw_args = args[: args.index("--")] if "--" in args else args
|
|
1622
|
+
ctx.obj["_raw_cli_args"] = tuple(raw_args)
|
|
1623
|
+
return super().parse_args(ctx, args)
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
def _should_skip_config_resolution(ctx: "click.Context") -> bool:
|
|
1627
|
+
if ctx.resilient_parsing:
|
|
1628
|
+
return True
|
|
1629
|
+
help_flags = set(ctx.help_option_names) | {"--help", "-h"}
|
|
1630
|
+
raw_args = ctx.obj.get("_raw_cli_args") if isinstance(ctx.obj, dict) else None
|
|
1631
|
+
if raw_args is not None:
|
|
1632
|
+
return any(arg in help_flags for arg in raw_args)
|
|
1633
|
+
argv_tail = sys.argv[1:]
|
|
1634
|
+
argv_args = argv_tail[: argv_tail.index("--")] if "--" in argv_tail else argv_tail
|
|
1635
|
+
return any(arg in help_flags for arg in argv_args)
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
def _safe_group_command(
|
|
1639
|
+
group: "Group", *, aliases: "list[str] | None" = None, **kwargs: Any
|
|
1640
|
+
) -> "Callable[[Callable[..., Any]], Callable[..., Any]]":
|
|
1641
|
+
if aliases is None:
|
|
1642
|
+
return group.command(**kwargs)
|
|
1643
|
+
try:
|
|
1644
|
+
return group.command(aliases=aliases, **kwargs)
|
|
1645
|
+
except TypeError:
|
|
1646
|
+
return group.command(**kwargs)
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
def _ensure_click_context() -> "click.Context":
|
|
1650
|
+
"""Return the active Click context, raising if missing (for type-checkers)."""
|
|
1651
|
+
|
|
1652
|
+
context = click.get_current_context()
|
|
1653
|
+
if context is None: # pragma: no cover
|
|
1654
|
+
msg = "SQLSpec CLI commands require an active Click context"
|
|
1655
|
+
raise RuntimeError(msg)
|
|
1656
|
+
return cast("click.Context", context)
|