sqlspec 0.72.0__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 6b29784d6b1cafc66758__mypyc.cp315-win_amd64.pyd +0 -0
- sqlspec/__init__.py +381 -0
- sqlspec/__main__.py +14 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_typing.py +775 -0
- sqlspec/adapters/__init__.py +3 -0
- sqlspec/adapters/adbc/__init__.py +16 -0
- sqlspec/adapters/adbc/_typing.py +221 -0
- sqlspec/adapters/adbc/adk/__init__.py +11 -0
- sqlspec/adapters/adbc/adk/store.py +4101 -0
- sqlspec/adapters/adbc/config.py +843 -0
- sqlspec/adapters/adbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/core.py +3209 -0
- sqlspec/adapters/adbc/data_dictionary.py +1448 -0
- sqlspec/adapters/adbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/driver.py +1400 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +384 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +962 -0
- sqlspec/adapters/adbc/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/pool.py +242 -0
- sqlspec/adapters/adbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/type_converter.py +117 -0
- sqlspec/adapters/aiomysql/__init__.py +25 -0
- sqlspec/adapters/aiomysql/_typing.py +134 -0
- sqlspec/adapters/aiomysql/adk/__init__.py +5 -0
- sqlspec/adapters/aiomysql/adk/store.py +1542 -0
- sqlspec/adapters/aiomysql/config.py +634 -0
- sqlspec/adapters/aiomysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/core.py +922 -0
- sqlspec/adapters/aiomysql/data_dictionary.py +16 -0
- sqlspec/adapters/aiomysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/driver.py +494 -0
- sqlspec/adapters/aiomysql/events/__init__.py +5 -0
- sqlspec/adapters/aiomysql/events/store.py +72 -0
- sqlspec/adapters/aiomysql/litestar/__init__.py +5 -0
- sqlspec/adapters/aiomysql/litestar/store.py +345 -0
- sqlspec/adapters/aiosqlite/__init__.py +43 -0
- sqlspec/adapters/aiosqlite/_typing.py +75 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +1546 -0
- sqlspec/adapters/aiosqlite/config.py +607 -0
- sqlspec/adapters/aiosqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/core.py +1155 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +343 -0
- sqlspec/adapters/aiosqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/driver.py +559 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +54 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +315 -0
- sqlspec/adapters/aiosqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/pool.py +1323 -0
- sqlspec/adapters/aiosqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/type_converter.py +114 -0
- sqlspec/adapters/arrow_odbc/__init__.py +32 -0
- sqlspec/adapters/arrow_odbc/_typing.py +131 -0
- sqlspec/adapters/arrow_odbc/adk/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/adk/store.py +1671 -0
- sqlspec/adapters/arrow_odbc/config.py +446 -0
- sqlspec/adapters/arrow_odbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/core.py +795 -0
- sqlspec/adapters/arrow_odbc/data_dictionary.py +345 -0
- sqlspec/adapters/arrow_odbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/driver.py +885 -0
- sqlspec/adapters/arrow_odbc/events/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/events/store.py +114 -0
- sqlspec/adapters/arrow_odbc/litestar/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/litestar/store.py +682 -0
- sqlspec/adapters/arrow_odbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/type_converter.py +95 -0
- sqlspec/adapters/asyncmy/__init__.py +27 -0
- sqlspec/adapters/asyncmy/_typing.py +215 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +1544 -0
- sqlspec/adapters/asyncmy/config.py +707 -0
- sqlspec/adapters/asyncmy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/core.py +917 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +16 -0
- sqlspec/adapters/asyncmy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/driver.py +529 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +72 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +348 -0
- sqlspec/adapters/asyncpg/__init__.py +28 -0
- sqlspec/adapters/asyncpg/_typing.py +113 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +1145 -0
- sqlspec/adapters/asyncpg/config.py +903 -0
- sqlspec/adapters/asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/core.py +797 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +417 -0
- sqlspec/adapters/asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/driver.py +927 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/events/_hub.py +279 -0
- sqlspec/adapters/asyncpg/events/backend.py +410 -0
- sqlspec/adapters/asyncpg/events/store.py +57 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +278 -0
- sqlspec/adapters/asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/tenant.py +140 -0
- sqlspec/adapters/bigquery/__init__.py +23 -0
- sqlspec/adapters/bigquery/_typing.py +184 -0
- sqlspec/adapters/bigquery/adk/__init__.py +5 -0
- sqlspec/adapters/bigquery/adk/store.py +920 -0
- sqlspec/adapters/bigquery/config.py +631 -0
- sqlspec/adapters/bigquery/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/core.py +1433 -0
- sqlspec/adapters/bigquery/data_dictionary.py +502 -0
- sqlspec/adapters/bigquery/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/driver.py +1266 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +158 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +359 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +32 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +54 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +9 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +1096 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +653 -0
- sqlspec/adapters/cockroach_asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +835 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +371 -0
- sqlspec/adapters/cockroach_asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +438 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +203 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.py +143 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +46 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +271 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +2274 -0
- sqlspec/adapters/cockroach_psycopg/config.py +1285 -0
- sqlspec/adapters/cockroach_psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +667 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +622 -0
- sqlspec/adapters/cockroach_psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +864 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +8 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +9 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +413 -0
- sqlspec/adapters/cockroach_psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/tenant.py +222 -0
- sqlspec/adapters/db2/__init__.py +34 -0
- sqlspec/adapters/db2/_typing.py +357 -0
- sqlspec/adapters/db2/adk/__init__.py +10 -0
- sqlspec/adapters/db2/adk/store.py +1950 -0
- sqlspec/adapters/db2/config.py +550 -0
- sqlspec/adapters/db2/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/core.py +1021 -0
- sqlspec/adapters/db2/data_dictionary.py +493 -0
- sqlspec/adapters/db2/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/driver.py +898 -0
- sqlspec/adapters/db2/events/__init__.py +5 -0
- sqlspec/adapters/db2/events/store.py +77 -0
- sqlspec/adapters/db2/litestar/__init__.py +5 -0
- sqlspec/adapters/db2/litestar/store.py +519 -0
- sqlspec/adapters/db2/migrations.py +221 -0
- sqlspec/adapters/db2/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/pool.py +876 -0
- sqlspec/adapters/db2/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/tenant.py +292 -0
- sqlspec/adapters/duckdb/__init__.py +30 -0
- sqlspec/adapters/duckdb/_typing.py +182 -0
- sqlspec/adapters/duckdb/adk/__init__.py +10 -0
- sqlspec/adapters/duckdb/adk/store.py +1672 -0
- sqlspec/adapters/duckdb/config.py +506 -0
- sqlspec/adapters/duckdb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/core.py +1299 -0
- sqlspec/adapters/duckdb/data_dictionary.py +553 -0
- sqlspec/adapters/duckdb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/driver.py +1214 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +38 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +313 -0
- sqlspec/adapters/duckdb/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/pool.py +1121 -0
- sqlspec/adapters/mssql_python/__init__.py +42 -0
- sqlspec/adapters/mssql_python/_typing.py +135 -0
- sqlspec/adapters/mssql_python/adk/__init__.py +5 -0
- sqlspec/adapters/mssql_python/adk/store.py +1278 -0
- sqlspec/adapters/mssql_python/config.py +455 -0
- sqlspec/adapters/mssql_python/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/core.py +862 -0
- sqlspec/adapters/mssql_python/data_dictionary.py +417 -0
- sqlspec/adapters/mssql_python/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/driver.py +772 -0
- sqlspec/adapters/mssql_python/events/__init__.py +5 -0
- sqlspec/adapters/mssql_python/events/store.py +46 -0
- sqlspec/adapters/mssql_python/litestar/__init__.py +5 -0
- sqlspec/adapters/mssql_python/litestar/store.py +355 -0
- sqlspec/adapters/mssql_python/migrations.py +162 -0
- sqlspec/adapters/mssql_python/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/pool.py +165 -0
- sqlspec/adapters/mssql_python/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/tenant.py +74 -0
- sqlspec/adapters/mssql_python/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/type_converter.py +98 -0
- sqlspec/adapters/mysqlconnector/__init__.py +47 -0
- sqlspec/adapters/mysqlconnector/_typing.py +205 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +17 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +2503 -0
- sqlspec/adapters/mysqlconnector/config.py +925 -0
- sqlspec/adapters/mysqlconnector/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/core.py +1075 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +23 -0
- sqlspec/adapters/mysqlconnector/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/driver.py +702 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +89 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +9 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +524 -0
- sqlspec/adapters/oracledb/__init__.py +159 -0
- sqlspec/adapters/oracledb/_json_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_json_handlers.py +208 -0
- sqlspec/adapters/oracledb/_param_types.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_param_types.py +65 -0
- sqlspec/adapters/oracledb/_plugins.py +137 -0
- sqlspec/adapters/oracledb/_storage.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_storage.py +138 -0
- sqlspec/adapters/oracledb/_typing.py +468 -0
- sqlspec/adapters/oracledb/_uuid_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +143 -0
- sqlspec/adapters/oracledb/_vector_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_vector_handlers.py +252 -0
- sqlspec/adapters/oracledb/adk/__init__.py +27 -0
- sqlspec/adapters/oracledb/adk/store.py +4031 -0
- sqlspec/adapters/oracledb/config.py +1785 -0
- sqlspec/adapters/oracledb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/core.py +5416 -0
- sqlspec/adapters/oracledb/data_dictionary.py +1264 -0
- sqlspec/adapters/oracledb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/driver.py +3273 -0
- sqlspec/adapters/oracledb/events/__init__.py +29 -0
- sqlspec/adapters/oracledb/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/events/_hub.py +394 -0
- sqlspec/adapters/oracledb/events/backend.py +311 -0
- sqlspec/adapters/oracledb/events/store.py +842 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +17 -0
- sqlspec/adapters/oracledb/litestar/store.py +862 -0
- sqlspec/adapters/oracledb/migrations.py +650 -0
- sqlspec/adapters/oracledb/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/tenant.py +990 -0
- sqlspec/adapters/oracledb/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/type_converter.py +93 -0
- sqlspec/adapters/psqlpy/__init__.py +21 -0
- sqlspec/adapters/psqlpy/_typing.py +180 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +1514 -0
- sqlspec/adapters/psqlpy/config.py +828 -0
- sqlspec/adapters/psqlpy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/core.py +1040 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +399 -0
- sqlspec/adapters/psqlpy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/driver.py +631 -0
- sqlspec/adapters/psqlpy/events/__init__.py +12 -0
- sqlspec/adapters/psqlpy/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/events/_hub.py +367 -0
- sqlspec/adapters/psqlpy/events/backend.py +415 -0
- sqlspec/adapters/psqlpy/events/store.py +46 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/tenant.py +137 -0
- sqlspec/adapters/psqlpy/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +21 -0
- sqlspec/adapters/psycopg/__init__.py +44 -0
- sqlspec/adapters/psycopg/_typing.py +408 -0
- sqlspec/adapters/psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/psycopg/adk/store.py +2761 -0
- sqlspec/adapters/psycopg/config.py +1522 -0
- sqlspec/adapters/psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/core.py +1001 -0
- sqlspec/adapters/psycopg/data_dictionary.py +701 -0
- sqlspec/adapters/psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/driver.py +1629 -0
- sqlspec/adapters/psycopg/events/__init__.py +25 -0
- sqlspec/adapters/psycopg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/events/_hub.py +646 -0
- sqlspec/adapters/psycopg/events/backend.py +739 -0
- sqlspec/adapters/psycopg/events/store.py +82 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +595 -0
- sqlspec/adapters/psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/tenant.py +226 -0
- sqlspec/adapters/psycopg/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/type_converter.py +94 -0
- sqlspec/adapters/pymssql/__init__.py +29 -0
- sqlspec/adapters/pymssql/_typing.py +156 -0
- sqlspec/adapters/pymssql/adk/__init__.py +5 -0
- sqlspec/adapters/pymssql/adk/store.py +1270 -0
- sqlspec/adapters/pymssql/config.py +299 -0
- sqlspec/adapters/pymssql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/core.py +527 -0
- sqlspec/adapters/pymssql/data_dictionary.py +417 -0
- sqlspec/adapters/pymssql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/driver.py +527 -0
- sqlspec/adapters/pymssql/events/__init__.py +5 -0
- sqlspec/adapters/pymssql/events/store.py +46 -0
- sqlspec/adapters/pymssql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymssql/litestar/store.py +350 -0
- sqlspec/adapters/pymssql/migrations.py +162 -0
- sqlspec/adapters/pymssql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/pool.py +417 -0
- sqlspec/adapters/pymssql/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/tenant.py +73 -0
- sqlspec/adapters/pymysql/__init__.py +27 -0
- sqlspec/adapters/pymysql/_typing.py +105 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +1646 -0
- sqlspec/adapters/pymysql/config.py +545 -0
- sqlspec/adapters/pymysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/core.py +909 -0
- sqlspec/adapters/pymysql/data_dictionary.py +16 -0
- sqlspec/adapters/pymysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/driver.py +370 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +42 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +299 -0
- sqlspec/adapters/pymysql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/pool.py +480 -0
- sqlspec/adapters/snowflake/__init__.py +36 -0
- sqlspec/adapters/snowflake/_typing.py +62 -0
- sqlspec/adapters/snowflake/adk/__init__.py +5 -0
- sqlspec/adapters/snowflake/adk/store.py +778 -0
- sqlspec/adapters/snowflake/config.py +333 -0
- sqlspec/adapters/snowflake/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/core.py +683 -0
- sqlspec/adapters/snowflake/data_dictionary.py +355 -0
- sqlspec/adapters/snowflake/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/driver.py +872 -0
- sqlspec/adapters/snowflake/events/__init__.py +5 -0
- sqlspec/adapters/snowflake/events/store.py +28 -0
- sqlspec/adapters/snowflake/litestar/__init__.py +5 -0
- sqlspec/adapters/snowflake/litestar/store.py +162 -0
- sqlspec/adapters/snowflake/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/migrations.py +76 -0
- sqlspec/adapters/snowflake/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/pool.py +385 -0
- sqlspec/adapters/snowflake/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/tenant.py +200 -0
- sqlspec/adapters/snowflake/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/type_converter.py +33 -0
- sqlspec/adapters/spanner/__init__.py +57 -0
- sqlspec/adapters/spanner/_typing.py +300 -0
- sqlspec/adapters/spanner/adk/__init__.py +22 -0
- sqlspec/adapters/spanner/adk/artifact_store.py +693 -0
- sqlspec/adapters/spanner/adk/store.py +3053 -0
- sqlspec/adapters/spanner/config.py +1578 -0
- sqlspec/adapters/spanner/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/core.py +1244 -0
- sqlspec/adapters/spanner/data_dictionary.py +706 -0
- sqlspec/adapters/spanner/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/driver.py +1673 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +357 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +570 -0
- sqlspec/adapters/spanner/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/type_converter.py +466 -0
- sqlspec/adapters/sqlanywhere/__init__.py +40 -0
- sqlspec/adapters/sqlanywhere/_typing.py +139 -0
- sqlspec/adapters/sqlanywhere/adk/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/adk/store.py +1136 -0
- sqlspec/adapters/sqlanywhere/config.py +359 -0
- sqlspec/adapters/sqlanywhere/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/core.py +583 -0
- sqlspec/adapters/sqlanywhere/data_dictionary.py +282 -0
- sqlspec/adapters/sqlanywhere/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/driver.py +480 -0
- sqlspec/adapters/sqlanywhere/events/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/events/store.py +28 -0
- sqlspec/adapters/sqlanywhere/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/litestar/store.py +237 -0
- sqlspec/adapters/sqlanywhere/migrations.py +178 -0
- sqlspec/adapters/sqlanywhere/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/pool.py +397 -0
- sqlspec/adapters/sqlite/__init__.py +32 -0
- sqlspec/adapters/sqlite/_typing.py +91 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +1628 -0
- sqlspec/adapters/sqlite/config.py +520 -0
- sqlspec/adapters/sqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/core.py +1035 -0
- sqlspec/adapters/sqlite/data_dictionary.py +327 -0
- sqlspec/adapters/sqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/driver.py +432 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +54 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +367 -0
- sqlspec/adapters/sqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/pool.py +935 -0
- sqlspec/adapters/sqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/adapters/sybase/__init__.py +37 -0
- sqlspec/adapters/sybase/_typing.py +150 -0
- sqlspec/adapters/sybase/adk/__init__.py +5 -0
- sqlspec/adapters/sybase/adk/store.py +1370 -0
- sqlspec/adapters/sybase/config.py +276 -0
- sqlspec/adapters/sybase/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/core.py +578 -0
- sqlspec/adapters/sybase/data_dictionary.py +358 -0
- sqlspec/adapters/sybase/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/driver.py +497 -0
- sqlspec/adapters/sybase/events/__init__.py +5 -0
- sqlspec/adapters/sybase/events/store.py +88 -0
- sqlspec/adapters/sybase/litestar/__init__.py +5 -0
- sqlspec/adapters/sybase/litestar/store.py +328 -0
- sqlspec/adapters/sybase/migrations.py +178 -0
- sqlspec/adapters/sybase/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/pool.py +435 -0
- sqlspec/adapters/teradata/__init__.py +59 -0
- sqlspec/adapters/teradata/_typing.py +145 -0
- sqlspec/adapters/teradata/adk/__init__.py +5 -0
- sqlspec/adapters/teradata/adk/store.py +1300 -0
- sqlspec/adapters/teradata/config.py +324 -0
- sqlspec/adapters/teradata/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/core.py +437 -0
- sqlspec/adapters/teradata/data_dictionary.py +316 -0
- sqlspec/adapters/teradata/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/driver.py +721 -0
- sqlspec/adapters/teradata/events/__init__.py +5 -0
- sqlspec/adapters/teradata/events/store.py +64 -0
- sqlspec/adapters/teradata/litestar/__init__.py +5 -0
- sqlspec/adapters/teradata/litestar/store.py +264 -0
- sqlspec/adapters/teradata/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/migrations.py +80 -0
- sqlspec/adapters/teradata/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/pool.py +377 -0
- sqlspec/adapters/teradata/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/type_converter.py +95 -0
- sqlspec/base.cp315-win_amd64.pyd +0 -0
- sqlspec/base.py +1275 -0
- sqlspec/builder/__init__.py +330 -0
- sqlspec/builder/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_base.py +1752 -0
- sqlspec/builder/_column.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_column.py +508 -0
- sqlspec/builder/_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_ddl.py +4503 -0
- sqlspec/builder/_delete.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_delete.py +75 -0
- sqlspec/builder/_dml.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_dml.py +639 -0
- sqlspec/builder/_explain.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_explain.py +650 -0
- sqlspec/builder/_expression_wrappers.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_expression_wrappers.py +77 -0
- sqlspec/builder/_factory.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_factory.py +1834 -0
- sqlspec/builder/_generation.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_generation.py +55 -0
- sqlspec/builder/_insert.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_insert.py +308 -0
- sqlspec/builder/_join.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_join.py +501 -0
- sqlspec/builder/_locking.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_locking.py +77 -0
- sqlspec/builder/_merge.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_merge.py +1047 -0
- sqlspec/builder/_parsing_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_parsing_utils.py +1197 -0
- sqlspec/builder/_select.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_select.py +1514 -0
- sqlspec/builder/_temporal.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_temporal.py +183 -0
- sqlspec/builder/_update.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_update.py +139 -0
- sqlspec/builder/_values.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_values.py +271 -0
- sqlspec/builder/_vector_distance.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_vector_distance.py +763 -0
- sqlspec/cli.py +1656 -0
- sqlspec/config.py +3402 -0
- sqlspec/core/__init__.py +542 -0
- sqlspec/core/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_cursor.py +564 -0
- sqlspec/core/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_operators.py +167 -0
- sqlspec/core/_ordering.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_ordering.py +151 -0
- sqlspec/core/_pagination.py +66 -0
- sqlspec/core/_pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pipeline.py +343 -0
- sqlspec/core/_pool.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pool.py +72 -0
- sqlspec/core/cache.cp315-win_amd64.pyd +0 -0
- sqlspec/core/cache.py +1503 -0
- sqlspec/core/capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/core/capabilities.py +67 -0
- sqlspec/core/compiler.cp315-win_amd64.pyd +0 -0
- sqlspec/core/compiler.py +1667 -0
- sqlspec/core/config_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/core/config_runtime.py +219 -0
- sqlspec/core/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/core/correlation.py +135 -0
- sqlspec/core/explain.cp315-win_amd64.pyd +0 -0
- sqlspec/core/explain.py +284 -0
- sqlspec/core/filters.cp315-win_amd64.pyd +0 -0
- sqlspec/core/filters.py +1442 -0
- sqlspec/core/hashing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/hashing.py +394 -0
- sqlspec/core/metrics.cp315-win_amd64.pyd +0 -0
- sqlspec/core/metrics.py +86 -0
- sqlspec/core/parameters/__init__.py +174 -0
- sqlspec/core/parameters/_alignment.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_alignment.py +321 -0
- sqlspec/core/parameters/_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_converter.py +956 -0
- sqlspec/core/parameters/_declared.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_declared.py +154 -0
- sqlspec/core/parameters/_processor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_processor.py +1646 -0
- sqlspec/core/parameters/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_registry.py +207 -0
- sqlspec/core/parameters/_transformers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_transformers.py +318 -0
- sqlspec/core/parameters/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_types.py +658 -0
- sqlspec/core/parameters/_validator.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_validator.py +699 -0
- sqlspec/core/query_modifiers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/query_modifiers.py +559 -0
- sqlspec/core/result/__init__.py +67 -0
- sqlspec/core/result/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/result/_base.py +1772 -0
- sqlspec/core/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/routing.py +270 -0
- sqlspec/core/splitter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/splitter.py +1126 -0
- sqlspec/core/sqlcommenter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/sqlcommenter.py +509 -0
- sqlspec/core/stack.cp315-win_amd64.pyd +0 -0
- sqlspec/core/stack.py +167 -0
- sqlspec/core/statement.cp315-win_amd64.pyd +0 -0
- sqlspec/core/statement.py +2253 -0
- sqlspec/core/tenant/__init__.py +64 -0
- sqlspec/core/tenant/base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/tenant/base.py +123 -0
- sqlspec/core/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/type_converter.py +147 -0
- sqlspec/data_dictionary/__init__.py +237 -0
- sqlspec/data_dictionary/_capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_capabilities.py +142 -0
- sqlspec/data_dictionary/_dependencies.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_dependencies.py +602 -0
- sqlspec/data_dictionary/_index_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_index_ddl.py +562 -0
- sqlspec/data_dictionary/_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_loader.py +344 -0
- sqlspec/data_dictionary/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_registry.py +152 -0
- sqlspec/data_dictionary/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_types.py +1852 -0
- sqlspec/data_dictionary/dialects/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/bigquery/__init__.py +15 -0
- sqlspec/data_dictionary/dialects/bigquery/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/bigquery/config.py +128 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/columns.sql +63 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/constraints.sql +37 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/datasets.sql +14 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/ddl.sql +51 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/dependencies.sql +22 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/indexes.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/routines.sql +50 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/system.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/tables.sql +111 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/views.sql +31 -0
- sqlspec/data_dictionary/dialects/cockroachdb/__init__.py +17 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.py +95 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/columns.sql +163 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/comments.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/crdb_internal.sql +11 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/ddl.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/dependencies.sql +20 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/foreign_keys.sql +62 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/indexes.sql +32 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/objects.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/tables.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/views.sql +11 -0
- sqlspec/data_dictionary/dialects/db2/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/db2/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/db2/config.py +172 -0
- sqlspec/data_dictionary/dialects/db2/sql/columns.sql +98 -0
- sqlspec/data_dictionary/dialects/db2/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/db2/sql/foreign_keys.sql +43 -0
- sqlspec/data_dictionary/dialects/db2/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/db2/sql/objects.sql +53 -0
- sqlspec/data_dictionary/dialects/db2/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/db2/sql/tables.sql +77 -0
- sqlspec/data_dictionary/dialects/db2/sql/version.sql +8 -0
- sqlspec/data_dictionary/dialects/db2/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/duckdb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/duckdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/duckdb/config.py +66 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/columns.sql +150 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/constraints.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/databases.sql +11 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/ddl.sql +221 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/dependencies.sql +50 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/extensions.sql +14 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/foreign_keys.sql +46 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/functions.sql +18 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/indexes.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/objects.sql +30 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/sequences.sql +19 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/system.sql +21 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/tables.sql +59 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/types.sql +12 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mariadb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/ddl.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/objects.sql +50 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/privileges.sql +24 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/system.sql +12 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mssql/__init__.py +51 -0
- sqlspec/data_dictionary/dialects/mssql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mssql/config.py +558 -0
- sqlspec/data_dictionary/dialects/mssql/sql/columns.sql +120 -0
- sqlspec/data_dictionary/dialects/mssql/sql/constraints.sql +106 -0
- sqlspec/data_dictionary/dialects/mssql/sql/ddl.sql +89 -0
- sqlspec/data_dictionary/dialects/mssql/sql/dependencies.sql +17 -0
- sqlspec/data_dictionary/dialects/mssql/sql/extended_properties.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/dialects/mssql/sql/indexes.sql +86 -0
- sqlspec/data_dictionary/dialects/mssql/sql/modules.sql +19 -0
- sqlspec/data_dictionary/dialects/mssql/sql/objects.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/permissions.sql +31 -0
- sqlspec/data_dictionary/dialects/mssql/sql/routines.sql +39 -0
- sqlspec/data_dictionary/dialects/mssql/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/mssql/sql/sequences.sql +18 -0
- sqlspec/data_dictionary/dialects/mssql/sql/storage.sql +22 -0
- sqlspec/data_dictionary/dialects/mssql/sql/system.sql +38 -0
- sqlspec/data_dictionary/dialects/mssql/sql/tables.sql +97 -0
- sqlspec/data_dictionary/dialects/mssql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mssql/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mssql/sql/views.sql +18 -0
- sqlspec/data_dictionary/dialects/mysql/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/mysql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mysql/config.py +363 -0
- sqlspec/data_dictionary/dialects/mysql/dictionary.py +650 -0
- sqlspec/data_dictionary/dialects/mysql/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mysql/sql/components.sql +8 -0
- sqlspec/data_dictionary/dialects/mysql/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mysql/sql/ddl.sql +23 -0
- sqlspec/data_dictionary/dialects/mysql/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mysql/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mysql/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mysql/sql/objects.sql +38 -0
- sqlspec/data_dictionary/dialects/mysql/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mysql/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mysql/sql/privileges.sql +26 -0
- sqlspec/data_dictionary/dialects/mysql/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mysql/sql/system.sql +25 -0
- sqlspec/data_dictionary/dialects/mysql/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mysql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/mysql/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/oracle/__init__.py +39 -0
- sqlspec/data_dictionary/dialects/oracle/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/oracle/config.py +266 -0
- sqlspec/data_dictionary/dialects/oracle/sql/arguments.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/columns.sql +103 -0
- sqlspec/data_dictionary/dialects/oracle/sql/comments.sql +22 -0
- sqlspec/data_dictionary/dialects/oracle/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/oracle/sql/ddl.sql +4 -0
- sqlspec/data_dictionary/dialects/oracle/sql/dependencies.sql +16 -0
- sqlspec/data_dictionary/dialects/oracle/sql/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/grants.sql +34 -0
- sqlspec/data_dictionary/dialects/oracle/sql/indexes.sql +87 -0
- sqlspec/data_dictionary/dialects/oracle/sql/lob_storage.sql +28 -0
- sqlspec/data_dictionary/dialects/oracle/sql/materialized_views.sql +27 -0
- sqlspec/data_dictionary/dialects/oracle/sql/objects.sql +26 -0
- sqlspec/data_dictionary/dialects/oracle/sql/partitions.sql +44 -0
- sqlspec/data_dictionary/dialects/oracle/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/sequences.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/source.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/system.sql +37 -0
- sqlspec/data_dictionary/dialects/oracle/sql/tables.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/triggers.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/version.sql +25 -0
- sqlspec/data_dictionary/dialects/oracle/sql/views.sql +49 -0
- sqlspec/data_dictionary/dialects/postgres/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/postgres/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/postgres/config.py +119 -0
- sqlspec/data_dictionary/dialects/postgres/sql/columns.sql +130 -0
- sqlspec/data_dictionary/dialects/postgres/sql/comments.sql +27 -0
- sqlspec/data_dictionary/dialects/postgres/sql/constraints.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/ddl.sql +55 -0
- sqlspec/data_dictionary/dialects/postgres/sql/dependencies.sql +42 -0
- sqlspec/data_dictionary/dialects/postgres/sql/extensions.sql +11 -0
- sqlspec/data_dictionary/dialects/postgres/sql/foreign_keys.sql +72 -0
- sqlspec/data_dictionary/dialects/postgres/sql/indexes.sql +84 -0
- sqlspec/data_dictionary/dialects/postgres/sql/materialized_views.sql +17 -0
- sqlspec/data_dictionary/dialects/postgres/sql/objects.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/partitions.sql +19 -0
- sqlspec/data_dictionary/dialects/postgres/sql/privileges.sql +29 -0
- sqlspec/data_dictionary/dialects/postgres/sql/routines.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/postgres/sql/sequences.sql +32 -0
- sqlspec/data_dictionary/dialects/postgres/sql/system.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/tables.sql +67 -0
- sqlspec/data_dictionary/dialects/postgres/sql/triggers.sql +20 -0
- sqlspec/data_dictionary/dialects/postgres/sql/types.sql +21 -0
- sqlspec/data_dictionary/dialects/postgres/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/postgres/sql/views.sql +17 -0
- sqlspec/data_dictionary/dialects/snowflake/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/snowflake/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/snowflake/config.py +321 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/columns.sql +48 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/constraints.sql +64 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/ddl.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/foreign_keys.sql +7 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/objects.sql +34 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/routines.sql +79 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/schemas.sql +19 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/sequences.sql +45 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/tables.sql +29 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/views.sql +37 -0
- sqlspec/data_dictionary/dialects/spanner/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/spanner/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/spanner/config.py +67 -0
- sqlspec/data_dictionary/dialects/spanner/sql/columns.sql +58 -0
- sqlspec/data_dictionary/dialects/spanner/sql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/columns.sql +46 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/database.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/indexes.sql +66 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/placements.sql +8 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/property_graphs.sql +11 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/routines.sql +33 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/tables.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/views.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/indexes.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/columns.sql +34 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/indexes.sql +52 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/spanner/sql/tables.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.py +191 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/columns.sql +97 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/constraints.sql +43 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/objects.sql +18 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/schemas.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/tables.sql +86 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlite/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/sqlite/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlite/config.py +412 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/columns.sql +59 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/compile_options.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/ddl.sql +37 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/functions.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/indexes.sql +76 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/modules.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/schemas.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/system.sql +7 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/triggers.sql +10 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/views.sql +10 -0
- sqlspec/data_dictionary/dialects/sybase/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sybase/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sybase/config.py +187 -0
- sqlspec/data_dictionary/dialects/sybase/sql/columns.sql +137 -0
- sqlspec/data_dictionary/dialects/sybase/sql/constraints.sql +85 -0
- sqlspec/data_dictionary/dialects/sybase/sql/foreign_keys.sql +81 -0
- sqlspec/data_dictionary/dialects/sybase/sql/indexes.sql +51 -0
- sqlspec/data_dictionary/dialects/sybase/sql/objects.sql +21 -0
- sqlspec/data_dictionary/dialects/sybase/sql/schemas.sql +16 -0
- sqlspec/data_dictionary/dialects/sybase/sql/tables.sql +46 -0
- sqlspec/data_dictionary/dialects/sybase/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sybase/sql/views.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/__init__.py +33 -0
- sqlspec/data_dictionary/dialects/teradata/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/teradata/config.py +228 -0
- sqlspec/data_dictionary/dialects/teradata/sql/columns.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/constraints.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/sql/foreign_keys.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/indexes.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/objects.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/schemas.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/version.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/views.sql +4 -0
- sqlspec/dialects/__init__.py +44 -0
- sqlspec/dialects/db2/__init__.py +111 -0
- sqlspec/dialects/db2/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_generators.py +376 -0
- sqlspec/dialects/db2/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_parsers.py +657 -0
- sqlspec/dialects/db2/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_transforms.py +175 -0
- sqlspec/dialects/postgres/__init__.py +10 -0
- sqlspec/dialects/postgres/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_generators.py +81 -0
- sqlspec/dialects/postgres/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_operators.py +95 -0
- sqlspec/dialects/postgres/_paradedb.py +44 -0
- sqlspec/dialects/postgres/_pg_textsearch.py +38 -0
- sqlspec/dialects/postgres/_pgvector.py +36 -0
- sqlspec/dialects/spanner/__init__.py +69 -0
- sqlspec/dialects/spanner/_expressions.py +247 -0
- sqlspec/dialects/spanner/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_generators.py +961 -0
- sqlspec/dialects/spanner/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_parsers.py +871 -0
- sqlspec/dialects/spanner/_spangres.py +43 -0
- sqlspec/dialects/spanner/_spanner.py +57 -0
- sqlspec/dialects/sybase/__init__.py +115 -0
- sqlspec/dialects/sybase/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_generators.py +379 -0
- sqlspec/dialects/sybase/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_parsers.py +225 -0
- sqlspec/dialects/sybase/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_transforms.py +68 -0
- sqlspec/dialects/teradata/__init__.py +42 -0
- sqlspec/dialects/teradata/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/teradata/_generators.py +203 -0
- sqlspec/driver/__init__.py +151 -0
- sqlspec/driver/_async.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_async.py +3244 -0
- sqlspec/driver/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_common.py +4765 -0
- sqlspec/driver/_deferred.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_deferred.py +232 -0
- sqlspec/driver/_exception_handler.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_exception_handler.py +224 -0
- sqlspec/driver/_routing.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_routing.py +2891 -0
- sqlspec/driver/_session.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_session.py +180 -0
- sqlspec/driver/_sql_helpers.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sql_helpers.py +140 -0
- sqlspec/driver/_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_stream.py +392 -0
- sqlspec/driver/_sync.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sync.py +3107 -0
- sqlspec/driver/_tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_tenant.py +326 -0
- sqlspec/exceptions.cp315-win_amd64.pyd +0 -0
- sqlspec/exceptions.py +568 -0
- sqlspec/extensions/__init__.py +3 -0
- sqlspec/extensions/adk/__init__.py +136 -0
- sqlspec/extensions/adk/_config_utils.py +306 -0
- sqlspec/extensions/adk/_table_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_table_utils.py +126 -0
- sqlspec/extensions/adk/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_types.py +59 -0
- sqlspec/extensions/adk/artifact/__init__.py +18 -0
- sqlspec/extensions/adk/artifact/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/artifact/_types.py +41 -0
- sqlspec/extensions/adk/artifact/service.py +657 -0
- sqlspec/extensions/adk/artifact/store.py +444 -0
- sqlspec/extensions/adk/converters.py +230 -0
- sqlspec/extensions/adk/maintenance.py +262 -0
- sqlspec/extensions/adk/memory/__init__.py +36 -0
- sqlspec/extensions/adk/memory/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/memory/_types.py +48 -0
- sqlspec/extensions/adk/memory/converters.py +271 -0
- sqlspec/extensions/adk/memory/service.py +474 -0
- sqlspec/extensions/adk/memory/store.py +586 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +181 -0
- sqlspec/extensions/adk/migrations/0002_create_mssql_python_memory.py +51 -0
- sqlspec/extensions/adk/migrations/__init__.py +3 -0
- sqlspec/extensions/adk/migrations/reconcile.py +282 -0
- sqlspec/extensions/adk/service.py +463 -0
- sqlspec/extensions/adk/store.py +1239 -0
- sqlspec/extensions/events/__init__.py +132 -0
- sqlspec/extensions/events/_buffer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_buffer.py +38 -0
- sqlspec/extensions/events/_channel.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_channel.py +1144 -0
- sqlspec/extensions/events/_hints.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_hints.py +38 -0
- sqlspec/extensions/events/_models.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_models.py +22 -0
- sqlspec/extensions/events/_names.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_names.py +27 -0
- sqlspec/extensions/events/_payload.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_payload.py +139 -0
- sqlspec/extensions/events/_protocols.py +154 -0
- sqlspec/extensions/events/_queue.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_queue.py +1147 -0
- sqlspec/extensions/events/_store.py +318 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +106 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/events/migrations/reconcile.py +145 -0
- sqlspec/extensions/events/primitives.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/primitives.py +91 -0
- sqlspec/extensions/fastapi/__init__.py +26 -0
- sqlspec/extensions/fastapi/extension.py +360 -0
- sqlspec/extensions/fastapi/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/fastapi/providers.py +1091 -0
- sqlspec/extensions/flask/__init__.py +20 -0
- sqlspec/extensions/flask/_portal.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_portal.py +212 -0
- sqlspec/extensions/flask/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_state.py +135 -0
- sqlspec/extensions/flask/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_utils.py +171 -0
- sqlspec/extensions/flask/extension.py +1234 -0
- sqlspec/extensions/litestar/__init__.py +52 -0
- sqlspec/extensions/litestar/_tenant_resolution.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_tenant_resolution.py +314 -0
- sqlspec/extensions/litestar/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_utils.py +222 -0
- sqlspec/extensions/litestar/channels.py +249 -0
- sqlspec/extensions/litestar/cli.py +100 -0
- sqlspec/extensions/litestar/config.py +5 -0
- sqlspec/extensions/litestar/handlers.py +796 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +138 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/migrations/reconcile.py +132 -0
- sqlspec/extensions/litestar/plugin.py +2172 -0
- sqlspec/extensions/litestar/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/providers.py +1239 -0
- sqlspec/extensions/litestar/store.py +613 -0
- sqlspec/extensions/litestar/tenant.py +292 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +5 -0
- sqlspec/extensions/prometheus/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/prometheus/_observer.py +152 -0
- sqlspec/extensions/sanic/__init__.py +28 -0
- sqlspec/extensions/sanic/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_state.py +102 -0
- sqlspec/extensions/sanic/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_utils.py +234 -0
- sqlspec/extensions/sanic/extension.py +1467 -0
- sqlspec/extensions/starlette/__init__.py +31 -0
- sqlspec/extensions/starlette/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_state.py +103 -0
- sqlspec/extensions/starlette/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_utils.py +267 -0
- sqlspec/extensions/starlette/extension.py +691 -0
- sqlspec/extensions/starlette/middleware.py +845 -0
- sqlspec/loader.cp315-win_amd64.pyd +0 -0
- sqlspec/loader.py +1733 -0
- sqlspec/migrations/__init__.py +104 -0
- sqlspec/migrations/_backup.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/_backup.py +36 -0
- sqlspec/migrations/base.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/base.py +1688 -0
- sqlspec/migrations/commands.py +4002 -0
- sqlspec/migrations/context.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/context.py +158 -0
- sqlspec/migrations/fix.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/fix.py +193 -0
- sqlspec/migrations/loaders.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/loaders.py +835 -0
- sqlspec/migrations/runner.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/runner.py +2144 -0
- sqlspec/migrations/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/schema.py +1266 -0
- sqlspec/migrations/squash.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/squash.py +2452 -0
- sqlspec/migrations/templates.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/templates.py +310 -0
- sqlspec/migrations/tracker.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/tracker.py +1529 -0
- sqlspec/migrations/utils.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/utils.py +534 -0
- sqlspec/migrations/validation.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/validation.py +355 -0
- sqlspec/migrations/version.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/version.py +455 -0
- sqlspec/observability/__init__.py +122 -0
- sqlspec/observability/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_common.py +307 -0
- sqlspec/observability/_config.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_config.py +362 -0
- sqlspec/observability/_diagnostics.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_diagnostics.py +75 -0
- sqlspec/observability/_dispatcher.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_dispatcher.py +320 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_aws.py +90 -0
- sqlspec/observability/_formatters/_azure.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_azure.py +84 -0
- sqlspec/observability/_formatters/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_base.py +40 -0
- sqlspec/observability/_formatters/_gcp.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_gcp.py +119 -0
- sqlspec/observability/_formatting.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatting.py +76 -0
- sqlspec/observability/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_observer.py +445 -0
- sqlspec/observability/_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_runtime.py +740 -0
- sqlspec/observability/_sampling.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_sampling.py +169 -0
- sqlspec/observability/_spans.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_spans.py +212 -0
- sqlspec/protocols.py +1235 -0
- sqlspec/py.typed +0 -0
- sqlspec/service/__init__.py +5 -0
- sqlspec/service/_base.py +1051 -0
- sqlspec/service/_core.cp315-win_amd64.pyd +0 -0
- sqlspec/service/_core.py +625 -0
- sqlspec/storage/__init__.py +111 -0
- sqlspec/storage/_arrow_payload.py +802 -0
- sqlspec/storage/_arrow_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_arrow_stream.py +134 -0
- sqlspec/storage/_ingest.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_ingest.py +810 -0
- sqlspec/storage/_paths.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_paths.py +313 -0
- sqlspec/storage/_staging_sql.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_staging_sql.py +695 -0
- sqlspec/storage/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_utils.py +174 -0
- sqlspec/storage/backends/__init__.py +43 -0
- sqlspec/storage/backends/base.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/base.py +399 -0
- sqlspec/storage/backends/fsspec.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/fsspec.py +1390 -0
- sqlspec/storage/backends/local.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/local.py +968 -0
- sqlspec/storage/backends/obstore.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/obstore.py +1974 -0
- sqlspec/storage/errors.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/errors.py +127 -0
- sqlspec/storage/pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/pipeline.py +1270 -0
- sqlspec/storage/registry.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/registry.py +318 -0
- sqlspec/typing.py +261 -0
- sqlspec/utils/__init__.py +9 -0
- sqlspec/utils/adapters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/adapters.py +186 -0
- sqlspec/utils/arrow_helpers.py +2157 -0
- sqlspec/utils/config_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/config_tools.py +712 -0
- sqlspec/utils/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/correlation.py +137 -0
- sqlspec/utils/deprecation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/deprecation.py +222 -0
- sqlspec/utils/dispatch.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/dispatch.py +104 -0
- sqlspec/utils/env.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/env.py +437 -0
- sqlspec/utils/fixtures.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/fixtures.py +2470 -0
- sqlspec/utils/logging.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/logging.py +267 -0
- sqlspec/utils/module_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/module_loader.py +399 -0
- sqlspec/utils/portal.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/portal.py +411 -0
- sqlspec/utils/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/routing.py +645 -0
- sqlspec/utils/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/schema.py +1050 -0
- sqlspec/utils/serializers/__init__.py +69 -0
- sqlspec/utils/serializers/_json.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_json.py +525 -0
- sqlspec/utils/serializers/_numpy.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_numpy.py +65 -0
- sqlspec/utils/serializers/_schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_schema.py +340 -0
- sqlspec/utils/sync_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/sync_tools.py +502 -0
- sqlspec/utils/tenant/__init__.py +71 -0
- sqlspec/utils/tenant/_context.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_context.py +550 -0
- sqlspec/utils/tenant/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_cursor.py +43 -0
- sqlspec/utils/tenant/_mssql.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_mssql.py +189 -0
- sqlspec/utils/tenant/_postgres.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_postgres.py +142 -0
- sqlspec/utils/text.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/text.py +317 -0
- sqlspec/utils/type_converters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_converters.py +220 -0
- sqlspec/utils/type_guards.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_guards.py +1505 -0
- sqlspec/utils/uuids.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/uuids.py +263 -0
- sqlspec-0.72.0.dist-info/METADATA +228 -0
- sqlspec-0.72.0.dist-info/RECORD +1144 -0
- sqlspec-0.72.0.dist-info/WHEEL +4 -0
- sqlspec-0.72.0.dist-info/entry_points.txt +13 -0
- sqlspec-0.72.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1239 @@
|
|
|
1
|
+
"""Base store class for ADK session backends."""
|
|
2
|
+
|
|
3
|
+
import inspect
|
|
4
|
+
import logging
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
from collections.abc import Generator
|
|
7
|
+
from contextlib import AbstractAsyncContextManager, AbstractContextManager, contextmanager
|
|
8
|
+
from contextvars import ContextVar
|
|
9
|
+
from datetime import UTC, datetime, timedelta
|
|
10
|
+
from typing import TYPE_CHECKING, Any, ClassVar, Final, Generic, TypeVar, cast
|
|
11
|
+
|
|
12
|
+
from sqlspec.exceptions import ImproperConfigurationError
|
|
13
|
+
from sqlspec.extensions.adk._config_utils import _adk_session_store_config
|
|
14
|
+
from sqlspec.extensions.adk._table_utils import (
|
|
15
|
+
ensure_table_name,
|
|
16
|
+
owner_id_column_name,
|
|
17
|
+
unique_statements,
|
|
18
|
+
validate_owner_id_column_ddl,
|
|
19
|
+
)
|
|
20
|
+
from sqlspec.migrations.schema import DropStatement, SchemaTarget, ensure_schema_async, ensure_schema_sync
|
|
21
|
+
from sqlspec.observability import resolve_db_system
|
|
22
|
+
from sqlspec.utils.adapters import resolve_adapter_name
|
|
23
|
+
from sqlspec.utils.logging import get_logger, log_with_context
|
|
24
|
+
from sqlspec.utils.routing import RoutingContext, is_valid_routing_token
|
|
25
|
+
from sqlspec.utils.sync_tools import async_
|
|
26
|
+
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
from sqlspec.config import DatabaseConfigProtocol
|
|
29
|
+
from sqlspec.extensions.adk._types import SessionOrderBy, StoredEvent, StoredSession
|
|
30
|
+
|
|
31
|
+
__all__ = ("BaseAsyncADKStore", "BaseSyncADKStore", "adk_primary_read_scope", "normalize_session_list_options")
|
|
32
|
+
|
|
33
|
+
ConfigT = TypeVar("ConfigT", bound="DatabaseConfigProtocol[Any, Any, Any]")
|
|
34
|
+
|
|
35
|
+
logger = get_logger("sqlspec.extensions.adk.store")
|
|
36
|
+
|
|
37
|
+
SESSION_ORDER_COLUMNS: Final = ("create_time", "update_time")
|
|
38
|
+
|
|
39
|
+
ADK_RESET_TABLE_PROFILES: Final = (
|
|
40
|
+
("adk_session", "adk_event", "adk_app_state", "adk_user_state", "adk_internal_metadata"),
|
|
41
|
+
("adk_session", "adk_event", "adk_app_state", "adk_user_state", "adk_metadata"),
|
|
42
|
+
("adk_sessions", "adk_events", "adk_app_states", "adk_user_states", "adk_internal_metadata"),
|
|
43
|
+
("adk_sessions", "adk_events", "adk_app_states", "adk_user_states", "adk_metadata"),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
_ADK_PRIMARY_READ: ContextVar[bool] = ContextVar("sqlspec_adk_primary_read", default=False)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@contextmanager
|
|
51
|
+
def adk_primary_read_scope() -> Generator[None, None, None]:
|
|
52
|
+
"""Keep reads inside a mutating ADK operation on the primary.
|
|
53
|
+
|
|
54
|
+
Yields:
|
|
55
|
+
None while the primary read directive is bound to this context.
|
|
56
|
+
"""
|
|
57
|
+
token = _ADK_PRIMARY_READ.set(True)
|
|
58
|
+
try:
|
|
59
|
+
yield
|
|
60
|
+
finally:
|
|
61
|
+
_ADK_PRIMARY_READ.reset(token)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class _ADKStoreCommon(Generic[ConfigT]):
|
|
65
|
+
"""Shared non-async ADK store state and helpers.
|
|
66
|
+
|
|
67
|
+
``extension_config_options`` names extra ``extension_config["adk"]`` keys that a store accepts when set as
|
|
68
|
+
``adk_store_class`` or ``adk_memory_store_class``.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
__slots__ = (
|
|
72
|
+
"_app_state_table",
|
|
73
|
+
"_config",
|
|
74
|
+
"_default_replica_group",
|
|
75
|
+
"_enable_replica_reads",
|
|
76
|
+
"_events_table",
|
|
77
|
+
"_metadata_table",
|
|
78
|
+
"_owner_id_column_ddl",
|
|
79
|
+
"_owner_id_column_name",
|
|
80
|
+
"_read_config",
|
|
81
|
+
"_session_table",
|
|
82
|
+
"_user_state_table",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
_max_table_name_parts: ClassVar[int] = 1
|
|
86
|
+
adapter_name: ClassVar[str | None] = None
|
|
87
|
+
extension_config_options: ClassVar[frozenset[str]] = frozenset()
|
|
88
|
+
|
|
89
|
+
def __init__(self, config: ConfigT, *, read_config: ConfigT | None = None) -> None:
|
|
90
|
+
"""Initialize the ADK store.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
config: SQLSpec database configuration.
|
|
94
|
+
read_config: Optional compatible configuration for pure reads.
|
|
95
|
+
|
|
96
|
+
Notes:
|
|
97
|
+
Reads configuration from config.extension_config["adk"]:
|
|
98
|
+
- session_table: Sessions table name (default: "adk_session")
|
|
99
|
+
- events_table: Events table name (default: "adk_event")
|
|
100
|
+
- app_state_table: App-scoped state table name (default: "adk_app_state")
|
|
101
|
+
- user_state_table: User-scoped state table name (default: "adk_user_state")
|
|
102
|
+
- metadata_table: Internal metadata table name (default: "adk_internal_metadata")
|
|
103
|
+
- owner_id_column: Optional owner FK column DDL (default: None)
|
|
104
|
+
"""
|
|
105
|
+
self._config = config
|
|
106
|
+
self._read_config = read_config
|
|
107
|
+
self._enable_replica_reads, self._default_replica_group = _resolve_adk_read_settings(config, read_config)
|
|
108
|
+
store_config = self._store_config_from_extension()
|
|
109
|
+
self._session_table: str = str(store_config["session_table"])
|
|
110
|
+
self._events_table: str = str(store_config["events_table"])
|
|
111
|
+
self._app_state_table: str = str(store_config["app_state_table"])
|
|
112
|
+
self._user_state_table: str = str(store_config["user_state_table"])
|
|
113
|
+
self._metadata_table: str = str(store_config["metadata_table"])
|
|
114
|
+
raw_owner_id_column_ddl: str | None = store_config.get("owner_id_column")
|
|
115
|
+
self._owner_id_column_ddl: str | None = (
|
|
116
|
+
validate_owner_id_column_ddl(raw_owner_id_column_ddl) if raw_owner_id_column_ddl is not None else None
|
|
117
|
+
)
|
|
118
|
+
self._owner_id_column_name: str | None = (
|
|
119
|
+
owner_id_column_name(self._owner_id_column_ddl) if self._owner_id_column_ddl is not None else None
|
|
120
|
+
)
|
|
121
|
+
ensure_table_name(self._session_table, max_parts=self._max_table_name_parts)
|
|
122
|
+
ensure_table_name(self._events_table, max_parts=self._max_table_name_parts)
|
|
123
|
+
ensure_table_name(self._app_state_table, max_parts=self._max_table_name_parts)
|
|
124
|
+
ensure_table_name(self._user_state_table, max_parts=self._max_table_name_parts)
|
|
125
|
+
ensure_table_name(self._metadata_table, max_parts=self._max_table_name_parts)
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def read_config(self) -> ConfigT | None:
|
|
129
|
+
"""Return the explicitly configured reader, when supplied."""
|
|
130
|
+
return self._read_config
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def enable_replica_reads(self) -> bool:
|
|
134
|
+
"""Return whether this store opts into pure-read offload."""
|
|
135
|
+
return self._enable_replica_reads
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def default_replica_group(self) -> str | None:
|
|
139
|
+
"""Return the configured named replica group for ADK reads."""
|
|
140
|
+
return self._default_replica_group
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def config(self) -> ConfigT:
|
|
144
|
+
"""Return the database configuration."""
|
|
145
|
+
return self._config
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def session_table(self) -> str:
|
|
149
|
+
"""Return the sessions table name."""
|
|
150
|
+
return self._session_table
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def events_table(self) -> str:
|
|
154
|
+
"""Return the events table name."""
|
|
155
|
+
return self._events_table
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def app_state_table(self) -> str:
|
|
159
|
+
"""Return the app-scoped state table name."""
|
|
160
|
+
return self._app_state_table
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def user_state_table(self) -> str:
|
|
164
|
+
"""Return the user-scoped state table name."""
|
|
165
|
+
return self._user_state_table
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def metadata_table(self) -> str:
|
|
169
|
+
"""Return the ADK metadata table name."""
|
|
170
|
+
return self._metadata_table
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def owner_id_column_ddl(self) -> "str | None":
|
|
174
|
+
"""Return the full owner ID column DDL (or None if not configured)."""
|
|
175
|
+
return self._owner_id_column_ddl
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def owner_id_column_name(self) -> "str | None":
|
|
179
|
+
"""Return the owner ID column name only (or None if not configured)."""
|
|
180
|
+
return self._owner_id_column_name
|
|
181
|
+
|
|
182
|
+
@property
|
|
183
|
+
def create_schema_enabled(self) -> bool:
|
|
184
|
+
"""Return whether adapter-level table creation should run."""
|
|
185
|
+
manage_schema, create_schema = self._schema_management_flags()
|
|
186
|
+
return manage_schema and create_schema
|
|
187
|
+
|
|
188
|
+
def downgrade_drops(self) -> "list[DropStatement]":
|
|
189
|
+
"""Return the extension-downgrade drops for the session store tables in FK-safe order."""
|
|
190
|
+
return [DropStatement(statement) for statement in self._drop_tables_sql()]
|
|
191
|
+
|
|
192
|
+
def _provide_replica_connection(
|
|
193
|
+
self, *, primary: bool = False, **kwargs: Any
|
|
194
|
+
) -> AbstractContextManager[Any] | AbstractAsyncContextManager[Any]:
|
|
195
|
+
return _provide_adk_read_context(
|
|
196
|
+
self._config,
|
|
197
|
+
self._read_config,
|
|
198
|
+
self._enable_replica_reads,
|
|
199
|
+
self._default_replica_group,
|
|
200
|
+
primary,
|
|
201
|
+
False,
|
|
202
|
+
kwargs,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
def _provide_replica_session(
|
|
206
|
+
self, *, primary: bool = False, **kwargs: Any
|
|
207
|
+
) -> AbstractContextManager[Any] | AbstractAsyncContextManager[Any]:
|
|
208
|
+
return _provide_adk_read_context(
|
|
209
|
+
self._config,
|
|
210
|
+
self._read_config,
|
|
211
|
+
self._enable_replica_reads,
|
|
212
|
+
self._default_replica_group,
|
|
213
|
+
primary,
|
|
214
|
+
True,
|
|
215
|
+
kwargs,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
def _drop_tables_sql(self) -> "list[str]":
|
|
219
|
+
"""Get the DROP TABLE SQL statements for this database dialect."""
|
|
220
|
+
raise NotImplementedError
|
|
221
|
+
|
|
222
|
+
def _reset_drop_statements(self) -> "list[str]":
|
|
223
|
+
"""Return all table drops needed before recreating the clean-break schema."""
|
|
224
|
+
statements = list(self._drop_tables_sql())
|
|
225
|
+
for table_profile in ADK_RESET_TABLE_PROFILES:
|
|
226
|
+
statements.extend(self._drop_sql_for_table_profile(table_profile))
|
|
227
|
+
return unique_statements(statements)
|
|
228
|
+
|
|
229
|
+
def _store_config_from_extension(self) -> "dict[str, Any]":
|
|
230
|
+
"""Extract ADK store configuration from config.extension_config.
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
Dict with ADK table names and optionally owner_id_column.
|
|
234
|
+
"""
|
|
235
|
+
return dict(_adk_session_store_config(self._config))
|
|
236
|
+
|
|
237
|
+
def _schema_management_flags(self) -> "tuple[bool, bool]":
|
|
238
|
+
"""Return automatic-management and missing-table creation flags."""
|
|
239
|
+
extension_config = cast("dict[str, Any]", self._config.extension_config)
|
|
240
|
+
settings = cast("dict[str, Any]", extension_config.get("adk", {}))
|
|
241
|
+
return bool(settings.get("manage_schema", True)), bool(settings.get("create_schema", True))
|
|
242
|
+
|
|
243
|
+
def _calculate_expires_at(self, expires_in: "int | timedelta | None") -> "datetime | None":
|
|
244
|
+
"""Calculate expiration timestamp from ``expires_in``.
|
|
245
|
+
|
|
246
|
+
Non-positive durations return an already-expired UTC timestamp rather than
|
|
247
|
+
``None`` so sessions expire immediately instead of becoming persistent.
|
|
248
|
+
|
|
249
|
+
Args:
|
|
250
|
+
expires_in: Seconds or timedelta until expiration, or ``None`` for no expiration.
|
|
251
|
+
|
|
252
|
+
Returns:
|
|
253
|
+
UTC datetime of expiration, or ``None`` when ``expires_in`` is ``None``.
|
|
254
|
+
"""
|
|
255
|
+
if expires_in is None:
|
|
256
|
+
return None
|
|
257
|
+
|
|
258
|
+
expires_in_seconds = expires_in.total_seconds() if isinstance(expires_in, timedelta) else float(expires_in)
|
|
259
|
+
|
|
260
|
+
if expires_in_seconds <= 0:
|
|
261
|
+
return datetime.now(UTC) - timedelta(microseconds=1)
|
|
262
|
+
|
|
263
|
+
return datetime.now(UTC) + timedelta(seconds=expires_in_seconds)
|
|
264
|
+
|
|
265
|
+
def _is_renewal_requested(self, renew_for: "int | timedelta | None") -> bool:
|
|
266
|
+
"""Return whether ``renew_for`` requests session expiration renewal.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
renew_for: Seconds or timedelta to extend expiration by, or ``None``.
|
|
270
|
+
|
|
271
|
+
Returns:
|
|
272
|
+
``True`` only when ``renew_for`` represents a positive duration.
|
|
273
|
+
"""
|
|
274
|
+
if renew_for is None:
|
|
275
|
+
return False
|
|
276
|
+
return (renew_for.total_seconds() if isinstance(renew_for, timedelta) else float(renew_for)) > 0
|
|
277
|
+
|
|
278
|
+
def _drop_sql_for_table_profile(self, table_profile: "tuple[str, str, str, str, str]") -> "list[str]":
|
|
279
|
+
session_table, events_table, app_state_table, user_state_table, metadata_table = table_profile
|
|
280
|
+
current_session_table = self._session_table
|
|
281
|
+
current_events_table = self._events_table
|
|
282
|
+
current_app_state_table = self._app_state_table
|
|
283
|
+
current_user_state_table = self._user_state_table
|
|
284
|
+
current_table = self._metadata_table
|
|
285
|
+
self._session_table = session_table
|
|
286
|
+
self._events_table = events_table
|
|
287
|
+
self._app_state_table = app_state_table
|
|
288
|
+
self._user_state_table = user_state_table
|
|
289
|
+
self._metadata_table = metadata_table
|
|
290
|
+
try:
|
|
291
|
+
return list(self._drop_tables_sql())
|
|
292
|
+
finally:
|
|
293
|
+
self._session_table = current_session_table
|
|
294
|
+
self._events_table = current_events_table
|
|
295
|
+
self._app_state_table = current_app_state_table
|
|
296
|
+
self._user_state_table = current_user_state_table
|
|
297
|
+
self._metadata_table = current_table
|
|
298
|
+
|
|
299
|
+
def _log_tables_created(self) -> None:
|
|
300
|
+
log_with_context(
|
|
301
|
+
logger,
|
|
302
|
+
logging.DEBUG,
|
|
303
|
+
"adk.tables.ready",
|
|
304
|
+
db_system=resolve_db_system(type(self).__name__),
|
|
305
|
+
session_table=self._session_table,
|
|
306
|
+
events_table=self._events_table,
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
def _log_tables_dropped(self) -> None:
|
|
310
|
+
log_with_context(
|
|
311
|
+
logger,
|
|
312
|
+
logging.DEBUG,
|
|
313
|
+
"adk.tables.dropped",
|
|
314
|
+
db_system=resolve_db_system(type(self).__name__),
|
|
315
|
+
session_table=self._session_table,
|
|
316
|
+
events_table=self._events_table,
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
def _log_tables_recreated(self) -> None:
|
|
320
|
+
log_with_context(
|
|
321
|
+
logger,
|
|
322
|
+
logging.DEBUG,
|
|
323
|
+
"adk.tables.recreated",
|
|
324
|
+
db_system=resolve_db_system(type(self).__name__),
|
|
325
|
+
session_table=self._session_table,
|
|
326
|
+
events_table=self._events_table,
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
class BaseAsyncADKStore(_ADKStoreCommon[ConfigT], ABC):
|
|
331
|
+
"""Base class for async SQLSpec-backed ADK session stores.
|
|
332
|
+
|
|
333
|
+
Implements storage operations for Google ADK sessions and events using
|
|
334
|
+
SQLSpec database adapters with async/await.
|
|
335
|
+
|
|
336
|
+
This abstract base class provides common functionality for all database-specific
|
|
337
|
+
store implementations including:
|
|
338
|
+
- Connection management via SQLSpec configs
|
|
339
|
+
- Table name validation
|
|
340
|
+
- Session and event CRUD operations
|
|
341
|
+
|
|
342
|
+
Subclasses must implement dialect-specific SQL queries and will be created
|
|
343
|
+
in each adapter directory (e.g., sqlspec/adapters/asyncpg/adk/store.py).
|
|
344
|
+
|
|
345
|
+
Args:
|
|
346
|
+
config: SQLSpec database configuration with extension_config["adk"] settings.
|
|
347
|
+
|
|
348
|
+
Notes:
|
|
349
|
+
Configuration is read from config.extension_config["adk"]:
|
|
350
|
+
- session_table: Sessions table name (default: "adk_session")
|
|
351
|
+
- events_table: Events table name (default: "adk_event")
|
|
352
|
+
- app_state_table: App-scoped state table name (default: "adk_app_state")
|
|
353
|
+
- user_state_table: User-scoped state table name (default: "adk_user_state")
|
|
354
|
+
- metadata_table: Internal metadata table name (default: "adk_internal_metadata")
|
|
355
|
+
- owner_id_column: Optional owner FK column DDL (default: None)
|
|
356
|
+
"""
|
|
357
|
+
|
|
358
|
+
__slots__ = ()
|
|
359
|
+
|
|
360
|
+
@abstractmethod
|
|
361
|
+
async def create_tables(self) -> None:
|
|
362
|
+
"""Create the sessions and events tables if they don't exist."""
|
|
363
|
+
raise NotImplementedError
|
|
364
|
+
|
|
365
|
+
async def prepare_schema_async(self, driver: Any) -> None:
|
|
366
|
+
"""Prepare adapter-specific schema decisions with an asynchronous driver."""
|
|
367
|
+
|
|
368
|
+
async def prepare_reconcile_async(self, driver: Any) -> None:
|
|
369
|
+
"""Run reconcile-only prerequisite DDL; the default does nothing."""
|
|
370
|
+
|
|
371
|
+
async def get_schema_targets_async(self, driver: Any) -> "list[SchemaTarget]":
|
|
372
|
+
"""Return session-store SchemaTarget definitions without opening a session."""
|
|
373
|
+
del driver
|
|
374
|
+
return await self._schema_targets()
|
|
375
|
+
|
|
376
|
+
async def reconcile_companion_objects_async(self, driver: Any) -> None:
|
|
377
|
+
"""Reconcile adapter-specific companion objects; the default does nothing."""
|
|
378
|
+
|
|
379
|
+
async def finalize_reconcile_async(self, driver: Any) -> None:
|
|
380
|
+
"""Refresh config state after every DDL phase succeeds; the default does nothing."""
|
|
381
|
+
|
|
382
|
+
@abstractmethod
|
|
383
|
+
async def create_session(
|
|
384
|
+
self,
|
|
385
|
+
session_id: str,
|
|
386
|
+
app_name: str,
|
|
387
|
+
user_id: str,
|
|
388
|
+
state: "dict[str, Any]",
|
|
389
|
+
owner_id: "Any | None" = None,
|
|
390
|
+
*,
|
|
391
|
+
app_state_delta: "dict[str, Any] | None" = None,
|
|
392
|
+
user_state_delta: "dict[str, Any] | None" = None,
|
|
393
|
+
) -> "StoredSession":
|
|
394
|
+
"""Create a new session and atomically merge any initial scoped state deltas.
|
|
395
|
+
|
|
396
|
+
Args:
|
|
397
|
+
session_id: Unique identifier for the session.
|
|
398
|
+
app_name: Name of the application.
|
|
399
|
+
user_id: ID of the user.
|
|
400
|
+
state: Session-scoped state dictionary.
|
|
401
|
+
owner_id: Optional owner ID value for owner_id_column (if configured).
|
|
402
|
+
app_state_delta: Delta of ``app:*`` keys to merge atomically into
|
|
403
|
+
the app state store inside the same transaction, or ``None``.
|
|
404
|
+
user_state_delta: Delta of ``user:*`` keys to merge atomically into
|
|
405
|
+
the user state store inside the same transaction, or ``None``.
|
|
406
|
+
|
|
407
|
+
Returns:
|
|
408
|
+
The created session record with its ``state`` merged with current
|
|
409
|
+
app and user state.
|
|
410
|
+
"""
|
|
411
|
+
raise NotImplementedError
|
|
412
|
+
|
|
413
|
+
@abstractmethod
|
|
414
|
+
async def get_session(
|
|
415
|
+
self, app_name: str, user_id: str, session_id: str, *, renew_for: "int | timedelta | None" = None
|
|
416
|
+
) -> "StoredSession | None":
|
|
417
|
+
"""Get a session.
|
|
418
|
+
|
|
419
|
+
Args:
|
|
420
|
+
app_name: Name of the application.
|
|
421
|
+
user_id: ID of the user.
|
|
422
|
+
session_id: Session identifier.
|
|
423
|
+
renew_for: If positive, touch the session update timestamp while reading.
|
|
424
|
+
|
|
425
|
+
Returns:
|
|
426
|
+
Session record if found, None otherwise.
|
|
427
|
+
"""
|
|
428
|
+
raise NotImplementedError
|
|
429
|
+
|
|
430
|
+
@abstractmethod
|
|
431
|
+
async def update_session_state(self, app_name: str, user_id: str, session_id: str, state: "dict[str, Any]") -> None:
|
|
432
|
+
"""Update session state.
|
|
433
|
+
|
|
434
|
+
Args:
|
|
435
|
+
app_name: Name of the application.
|
|
436
|
+
user_id: ID of the user.
|
|
437
|
+
session_id: Session identifier.
|
|
438
|
+
state: New state dictionary.
|
|
439
|
+
"""
|
|
440
|
+
raise NotImplementedError
|
|
441
|
+
|
|
442
|
+
@abstractmethod
|
|
443
|
+
async def list_sessions(
|
|
444
|
+
self,
|
|
445
|
+
app_name: str,
|
|
446
|
+
user_id: "str | None" = None,
|
|
447
|
+
*,
|
|
448
|
+
order_by: "SessionOrderBy" = "update_time",
|
|
449
|
+
descending: bool = True,
|
|
450
|
+
limit: "int | None" = None,
|
|
451
|
+
offset: "int | None" = None,
|
|
452
|
+
) -> "list[StoredSession]":
|
|
453
|
+
"""List all sessions for an app, optionally filtered by user.
|
|
454
|
+
|
|
455
|
+
Args:
|
|
456
|
+
app_name: Name of the application.
|
|
457
|
+
user_id: ID of the user. If None, returns all sessions for the app.
|
|
458
|
+
order_by: Timestamp column to sort on.
|
|
459
|
+
descending: Sort direction applied to the timestamp column and the
|
|
460
|
+
``id`` tie-break.
|
|
461
|
+
limit: Maximum number of sessions to return. ``0`` returns an empty
|
|
462
|
+
list without database work.
|
|
463
|
+
offset: Number of leading rows to skip. Requires a finite limit
|
|
464
|
+
when positive.
|
|
465
|
+
|
|
466
|
+
Returns:
|
|
467
|
+
List of session records.
|
|
468
|
+
"""
|
|
469
|
+
raise NotImplementedError
|
|
470
|
+
|
|
471
|
+
@abstractmethod
|
|
472
|
+
async def delete_session(self, app_name: str, user_id: str, session_id: str) -> None:
|
|
473
|
+
"""Delete a session and its events.
|
|
474
|
+
|
|
475
|
+
Args:
|
|
476
|
+
app_name: Name of the application.
|
|
477
|
+
user_id: ID of the user.
|
|
478
|
+
session_id: Session identifier.
|
|
479
|
+
"""
|
|
480
|
+
raise NotImplementedError
|
|
481
|
+
|
|
482
|
+
@abstractmethod
|
|
483
|
+
async def append_event(self, event_record: "StoredEvent") -> None:
|
|
484
|
+
"""Append an event to a session.
|
|
485
|
+
|
|
486
|
+
Args:
|
|
487
|
+
event_record: Event record to insert.
|
|
488
|
+
"""
|
|
489
|
+
raise NotImplementedError
|
|
490
|
+
|
|
491
|
+
@abstractmethod
|
|
492
|
+
async def append_event_and_update_state(
|
|
493
|
+
self,
|
|
494
|
+
event_record: "StoredEvent",
|
|
495
|
+
app_name: str,
|
|
496
|
+
user_id: str,
|
|
497
|
+
session_id: str,
|
|
498
|
+
state: "dict[str, Any]",
|
|
499
|
+
*,
|
|
500
|
+
app_state_delta: "dict[str, Any] | None" = None,
|
|
501
|
+
user_state_delta: "dict[str, Any] | None" = None,
|
|
502
|
+
) -> "StoredSession":
|
|
503
|
+
"""Atomically append an event and merge session and scoped state deltas.
|
|
504
|
+
|
|
505
|
+
This is the authoritative durable write boundary for post-creation
|
|
506
|
+
mutations. When ``app_state_delta`` or ``user_state_delta`` is provided,
|
|
507
|
+
the store merges those keys atomically into the durable app or user
|
|
508
|
+
state inside the store transaction instead of overwriting concurrent
|
|
509
|
+
writes. ``None`` or empty deltas leave the corresponding scoped row
|
|
510
|
+
untouched.
|
|
511
|
+
|
|
512
|
+
Args:
|
|
513
|
+
event_record: Event record to store.
|
|
514
|
+
app_name: Application name for routing scoped-state merges.
|
|
515
|
+
user_id: User identifier for routing user-scoped merges.
|
|
516
|
+
session_id: Session identifier whose state should be updated.
|
|
517
|
+
state: Post-append durable session-scoped state snapshot
|
|
518
|
+
(``temp:`` keys already stripped by the service layer).
|
|
519
|
+
app_state_delta: Delta of ``app:*`` keys to merge atomically into
|
|
520
|
+
the durable app state, or ``None`` when untouched.
|
|
521
|
+
user_state_delta: Delta of ``user:*`` keys to merge atomically into
|
|
522
|
+
the durable user state, or ``None`` when untouched.
|
|
523
|
+
|
|
524
|
+
Returns:
|
|
525
|
+
The updated StoredSession reflecting the new session state merged
|
|
526
|
+
with any updated app and user state scopes and the new update_time.
|
|
527
|
+
|
|
528
|
+
Raises:
|
|
529
|
+
ValueError: If the session row no longer exists at update time
|
|
530
|
+
(raced with delete_session).
|
|
531
|
+
"""
|
|
532
|
+
raise NotImplementedError
|
|
533
|
+
|
|
534
|
+
@abstractmethod
|
|
535
|
+
async def get_events(
|
|
536
|
+
self,
|
|
537
|
+
app_name: str,
|
|
538
|
+
user_id: str,
|
|
539
|
+
session_id: str,
|
|
540
|
+
after_timestamp: "datetime | None" = None,
|
|
541
|
+
limit: "int | None" = None,
|
|
542
|
+
) -> "list[StoredEvent]":
|
|
543
|
+
"""Get events for a session.
|
|
544
|
+
|
|
545
|
+
Args:
|
|
546
|
+
app_name: Name of the application.
|
|
547
|
+
user_id: ID of the user.
|
|
548
|
+
session_id: Session identifier.
|
|
549
|
+
after_timestamp: Only return events after this time.
|
|
550
|
+
limit: Maximum number of most recent events to return.
|
|
551
|
+
|
|
552
|
+
Returns:
|
|
553
|
+
List of event records ordered by timestamp ascending.
|
|
554
|
+
"""
|
|
555
|
+
raise NotImplementedError
|
|
556
|
+
|
|
557
|
+
@abstractmethod
|
|
558
|
+
async def delete_expired_events(self, before: datetime, app_name: "str | None" = None) -> int:
|
|
559
|
+
"""Delete events older than the given timestamp.
|
|
560
|
+
|
|
561
|
+
Args:
|
|
562
|
+
before: Timestamp threshold; events with timestamp earlier than this value are deleted.
|
|
563
|
+
app_name: When given, restrict deletion to events belonging to this application.
|
|
564
|
+
|
|
565
|
+
Returns:
|
|
566
|
+
Number of event rows deleted.
|
|
567
|
+
"""
|
|
568
|
+
raise NotImplementedError
|
|
569
|
+
|
|
570
|
+
@abstractmethod
|
|
571
|
+
async def delete_idle_user_states(self, updated_before: datetime, app_name: "str | None" = None) -> int:
|
|
572
|
+
"""Delete user-scoped state rows whose update_time predates the given threshold.
|
|
573
|
+
|
|
574
|
+
Args:
|
|
575
|
+
updated_before: Timestamp threshold; rows updated earlier than this value are deleted.
|
|
576
|
+
app_name: When given, restrict deletion to rows belonging to this application.
|
|
577
|
+
|
|
578
|
+
Returns:
|
|
579
|
+
Number of user state rows deleted.
|
|
580
|
+
"""
|
|
581
|
+
raise NotImplementedError
|
|
582
|
+
|
|
583
|
+
@abstractmethod
|
|
584
|
+
async def delete_idle_sessions(self, updated_before: datetime, app_name: "str | None" = None) -> int:
|
|
585
|
+
"""Delete sessions whose update_time predates the given threshold.
|
|
586
|
+
|
|
587
|
+
Args:
|
|
588
|
+
updated_before: Timestamp threshold; sessions updated earlier than this value are deleted.
|
|
589
|
+
app_name: When given, restrict deletion to sessions belonging to this application.
|
|
590
|
+
|
|
591
|
+
Returns:
|
|
592
|
+
Number of session rows deleted.
|
|
593
|
+
"""
|
|
594
|
+
raise NotImplementedError
|
|
595
|
+
|
|
596
|
+
@abstractmethod
|
|
597
|
+
async def get_app_state(self, app_name: str) -> "dict[str, Any] | None":
|
|
598
|
+
"""Return app-scoped state for an application.
|
|
599
|
+
|
|
600
|
+
Args:
|
|
601
|
+
app_name: Application name.
|
|
602
|
+
|
|
603
|
+
Returns:
|
|
604
|
+
App-scoped state mapping if present, otherwise ``None``.
|
|
605
|
+
"""
|
|
606
|
+
raise NotImplementedError
|
|
607
|
+
|
|
608
|
+
@abstractmethod
|
|
609
|
+
async def get_user_state(self, app_name: str, user_id: str) -> "dict[str, Any] | None":
|
|
610
|
+
"""Return user-scoped state for an application user.
|
|
611
|
+
|
|
612
|
+
Args:
|
|
613
|
+
app_name: Application name.
|
|
614
|
+
user_id: User identifier.
|
|
615
|
+
|
|
616
|
+
Returns:
|
|
617
|
+
User-scoped state mapping if present, otherwise ``None``.
|
|
618
|
+
"""
|
|
619
|
+
raise NotImplementedError
|
|
620
|
+
|
|
621
|
+
@abstractmethod
|
|
622
|
+
async def upsert_app_state(self, app_name: str, state: "dict[str, Any]") -> None:
|
|
623
|
+
"""Insert or replace app-scoped state for an application.
|
|
624
|
+
|
|
625
|
+
Args:
|
|
626
|
+
app_name: Application name.
|
|
627
|
+
state: App-scoped state mapping.
|
|
628
|
+
"""
|
|
629
|
+
raise NotImplementedError
|
|
630
|
+
|
|
631
|
+
@abstractmethod
|
|
632
|
+
async def upsert_user_state(self, app_name: str, user_id: str, state: "dict[str, Any]") -> None:
|
|
633
|
+
"""Insert or replace user-scoped state for an application user.
|
|
634
|
+
|
|
635
|
+
Args:
|
|
636
|
+
app_name: Application name.
|
|
637
|
+
user_id: User identifier.
|
|
638
|
+
state: User-scoped state mapping.
|
|
639
|
+
"""
|
|
640
|
+
raise NotImplementedError
|
|
641
|
+
|
|
642
|
+
@abstractmethod
|
|
643
|
+
async def get_metadata(self, key: str) -> "str | None":
|
|
644
|
+
"""Return a value from the ADK internal metadata table.
|
|
645
|
+
|
|
646
|
+
Args:
|
|
647
|
+
key: Metadata key.
|
|
648
|
+
|
|
649
|
+
Returns:
|
|
650
|
+
Metadata value if present, otherwise ``None``.
|
|
651
|
+
"""
|
|
652
|
+
raise NotImplementedError
|
|
653
|
+
|
|
654
|
+
@abstractmethod
|
|
655
|
+
async def set_metadata(self, key: str, value: str) -> None:
|
|
656
|
+
"""Set a value in the ADK internal metadata table.
|
|
657
|
+
|
|
658
|
+
Args:
|
|
659
|
+
key: Metadata key.
|
|
660
|
+
value: Metadata value.
|
|
661
|
+
"""
|
|
662
|
+
raise NotImplementedError
|
|
663
|
+
|
|
664
|
+
async def reconcile_schema(self, *, assume_existing: bool = False) -> None:
|
|
665
|
+
"""Apply additive ADK table changes from canonical adapter DDL.
|
|
666
|
+
|
|
667
|
+
Args:
|
|
668
|
+
assume_existing: Skip table discovery after adapter-level creation.
|
|
669
|
+
"""
|
|
670
|
+
manage_schema, create_schema = self._schema_management_flags()
|
|
671
|
+
if not manage_schema:
|
|
672
|
+
return
|
|
673
|
+
targets = await self._schema_targets()
|
|
674
|
+
session_context = self._config.provide_session()
|
|
675
|
+
if hasattr(session_context, "__aenter__"):
|
|
676
|
+
async with cast("Any", session_context) as driver:
|
|
677
|
+
await ensure_schema_async(
|
|
678
|
+
driver, targets, manage_schema=True, create_schema=create_schema, assume_existing=assume_existing
|
|
679
|
+
)
|
|
680
|
+
return
|
|
681
|
+
await async_(_reconcile_adk_schema_sync)(
|
|
682
|
+
self._config, targets, create_schema=create_schema, assume_existing=assume_existing
|
|
683
|
+
)
|
|
684
|
+
|
|
685
|
+
async def ensure_tables(self) -> None:
|
|
686
|
+
"""Create tables and emit a standardized log entry."""
|
|
687
|
+
|
|
688
|
+
if self.create_schema_enabled:
|
|
689
|
+
await self.create_tables()
|
|
690
|
+
await self.reconcile_schema(assume_existing=self.create_schema_enabled)
|
|
691
|
+
self._log_tables_created()
|
|
692
|
+
|
|
693
|
+
async def drop_tables(self) -> None:
|
|
694
|
+
"""Drop all ADK tables managed by this store in FK-safe order."""
|
|
695
|
+
await self._execute_lifecycle_scripts(self._drop_tables_sql())
|
|
696
|
+
self._log_tables_dropped()
|
|
697
|
+
|
|
698
|
+
async def recreate_tables(self) -> None:
|
|
699
|
+
"""Drop and recreate all ADK tables managed by this store."""
|
|
700
|
+
await self.drop_tables()
|
|
701
|
+
await self.ensure_tables()
|
|
702
|
+
self._log_tables_recreated()
|
|
703
|
+
|
|
704
|
+
async def _schema_targets(self) -> "list[SchemaTarget]":
|
|
705
|
+
"""Construct SchemaTarget definitions for all ADK session tables."""
|
|
706
|
+
statement_config = getattr(self._config, "statement_config", None)
|
|
707
|
+
dialect = getattr(statement_config, "dialect", None)
|
|
708
|
+
ddl_targets = (
|
|
709
|
+
(self._session_table, await self._sessions_table_ddl()),
|
|
710
|
+
(self._events_table, await self._events_table_ddl()),
|
|
711
|
+
(self._app_state_table, await self._app_states_table_ddl()),
|
|
712
|
+
(self._user_state_table, await self._user_states_table_ddl()),
|
|
713
|
+
(self._metadata_table, await self._metadata_table_ddl()),
|
|
714
|
+
)
|
|
715
|
+
return [SchemaTarget.from_ddl(table, ddl, dialect=dialect) for table, ddl in ddl_targets]
|
|
716
|
+
|
|
717
|
+
async def _execute_lifecycle_scripts(self, statements: list[str]) -> None:
|
|
718
|
+
"""Execute lifecycle DDL scripts for async and sync-backed configs."""
|
|
719
|
+
session_context = self._config.provide_session()
|
|
720
|
+
if hasattr(session_context, "__aenter__"):
|
|
721
|
+
async with cast("Any", session_context) as driver:
|
|
722
|
+
for statement in statements:
|
|
723
|
+
result = driver.execute_script(statement)
|
|
724
|
+
if inspect.isawaitable(result):
|
|
725
|
+
await result
|
|
726
|
+
commit = getattr(driver, "commit", None)
|
|
727
|
+
if callable(commit):
|
|
728
|
+
result = commit()
|
|
729
|
+
if inspect.isawaitable(result):
|
|
730
|
+
await result
|
|
731
|
+
return
|
|
732
|
+
|
|
733
|
+
await async_(_run_lifecycle_sync)(self._config, statements)
|
|
734
|
+
|
|
735
|
+
@abstractmethod
|
|
736
|
+
async def _sessions_table_ddl(self) -> str:
|
|
737
|
+
"""Get the CREATE TABLE SQL for the sessions table.
|
|
738
|
+
|
|
739
|
+
Returns:
|
|
740
|
+
SQL statement to create the sessions table.
|
|
741
|
+
"""
|
|
742
|
+
raise NotImplementedError
|
|
743
|
+
|
|
744
|
+
@abstractmethod
|
|
745
|
+
async def _events_table_ddl(self) -> str:
|
|
746
|
+
"""Get the CREATE TABLE SQL for the events table.
|
|
747
|
+
|
|
748
|
+
Returns:
|
|
749
|
+
SQL statement to create the events table.
|
|
750
|
+
"""
|
|
751
|
+
raise NotImplementedError
|
|
752
|
+
|
|
753
|
+
@abstractmethod
|
|
754
|
+
async def _app_states_table_ddl(self) -> str:
|
|
755
|
+
"""Get the CREATE TABLE SQL for the app-scoped state table.
|
|
756
|
+
|
|
757
|
+
Returns:
|
|
758
|
+
SQL statement to create the app-scoped state table.
|
|
759
|
+
"""
|
|
760
|
+
raise NotImplementedError
|
|
761
|
+
|
|
762
|
+
@abstractmethod
|
|
763
|
+
async def _user_states_table_ddl(self) -> str:
|
|
764
|
+
"""Get the CREATE TABLE SQL for the user-scoped state table.
|
|
765
|
+
|
|
766
|
+
Returns:
|
|
767
|
+
SQL statement to create the user-scoped state table.
|
|
768
|
+
"""
|
|
769
|
+
raise NotImplementedError
|
|
770
|
+
|
|
771
|
+
@abstractmethod
|
|
772
|
+
async def _metadata_table_ddl(self) -> str:
|
|
773
|
+
"""Get the CREATE TABLE SQL for the ADK internal metadata table.
|
|
774
|
+
|
|
775
|
+
Returns:
|
|
776
|
+
SQL statement to create the ADK internal metadata table.
|
|
777
|
+
"""
|
|
778
|
+
raise NotImplementedError
|
|
779
|
+
|
|
780
|
+
@abstractmethod
|
|
781
|
+
def _drop_app_states_table_sql(self) -> str:
|
|
782
|
+
"""Get the DROP TABLE SQL statement for the app-scoped state table.
|
|
783
|
+
|
|
784
|
+
Returns:
|
|
785
|
+
SQL statement to drop the app-scoped state table.
|
|
786
|
+
"""
|
|
787
|
+
raise NotImplementedError
|
|
788
|
+
|
|
789
|
+
@abstractmethod
|
|
790
|
+
def _drop_user_states_table_sql(self) -> str:
|
|
791
|
+
"""Get the DROP TABLE SQL statement for the user-scoped state table.
|
|
792
|
+
|
|
793
|
+
Returns:
|
|
794
|
+
SQL statement to drop the user-scoped state table.
|
|
795
|
+
"""
|
|
796
|
+
raise NotImplementedError
|
|
797
|
+
|
|
798
|
+
@abstractmethod
|
|
799
|
+
def _drop_metadata_table_sql(self) -> str:
|
|
800
|
+
"""Get the DROP TABLE SQL statement for the ADK internal metadata table.
|
|
801
|
+
|
|
802
|
+
Returns:
|
|
803
|
+
SQL statement to drop the ADK internal metadata table.
|
|
804
|
+
"""
|
|
805
|
+
raise NotImplementedError
|
|
806
|
+
|
|
807
|
+
@abstractmethod
|
|
808
|
+
def _drop_tables_sql(self) -> "list[str]":
|
|
809
|
+
"""Get the DROP TABLE SQL statements for this database dialect.
|
|
810
|
+
|
|
811
|
+
Returns:
|
|
812
|
+
List of SQL statements to drop the tables and all indexes.
|
|
813
|
+
Order matters: drop events table before sessions table due to FK.
|
|
814
|
+
|
|
815
|
+
Notes:
|
|
816
|
+
Should use IF EXISTS or dialect-specific error handling
|
|
817
|
+
to allow idempotent migrations.
|
|
818
|
+
"""
|
|
819
|
+
raise NotImplementedError
|
|
820
|
+
|
|
821
|
+
async def _reset_drop_tables_sql(self) -> "list[str]":
|
|
822
|
+
"""Return the drops that remove configured and legacy ADK session tables."""
|
|
823
|
+
return self._reset_drop_statements()
|
|
824
|
+
|
|
825
|
+
def _provide_replica_connection(self, *, primary: bool = False, **kwargs: Any) -> AbstractAsyncContextManager[Any]:
|
|
826
|
+
return cast("AbstractAsyncContextManager[Any]", super()._provide_replica_connection(primary=primary, **kwargs))
|
|
827
|
+
|
|
828
|
+
def _provide_replica_session(self, *, primary: bool = False, **kwargs: Any) -> AbstractAsyncContextManager[Any]:
|
|
829
|
+
return cast("AbstractAsyncContextManager[Any]", super()._provide_replica_session(primary=primary, **kwargs))
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
class BaseSyncADKStore(_ADKStoreCommon[ConfigT], ABC):
|
|
833
|
+
"""Base class for sync SQLSpec-backed ADK session stores.
|
|
834
|
+
|
|
835
|
+
Sync-backed adapters expose a real synchronous API for direct use in
|
|
836
|
+
synchronous applications. Async bridging belongs in ``SQLSpecSessionService``
|
|
837
|
+
when Google ADK calls into a sync store from its async service surface.
|
|
838
|
+
|
|
839
|
+
Args:
|
|
840
|
+
config: SQLSpec database configuration with extension_config["adk"] settings.
|
|
841
|
+
"""
|
|
842
|
+
|
|
843
|
+
__slots__ = ()
|
|
844
|
+
|
|
845
|
+
@abstractmethod
|
|
846
|
+
def create_tables(self) -> None:
|
|
847
|
+
"""Create the sessions and events tables if they don't exist."""
|
|
848
|
+
raise NotImplementedError
|
|
849
|
+
|
|
850
|
+
def prepare_schema_sync(self, driver: Any) -> None:
|
|
851
|
+
"""Prepare adapter-specific schema decisions with a synchronous driver."""
|
|
852
|
+
|
|
853
|
+
def prepare_reconcile_sync(self, driver: Any) -> None:
|
|
854
|
+
"""Run reconcile-only prerequisite DDL; the default does nothing."""
|
|
855
|
+
|
|
856
|
+
def get_schema_targets_sync(self, driver: Any) -> "list[SchemaTarget]":
|
|
857
|
+
"""Return session-store SchemaTarget definitions without opening a session."""
|
|
858
|
+
del driver
|
|
859
|
+
return self._schema_targets()
|
|
860
|
+
|
|
861
|
+
def reconcile_companion_objects_sync(self, driver: Any) -> None:
|
|
862
|
+
"""Reconcile adapter-specific companion objects; the default does nothing."""
|
|
863
|
+
|
|
864
|
+
def finalize_reconcile_sync(self, driver: Any) -> None:
|
|
865
|
+
"""Refresh config state after every DDL phase succeeds; the default does nothing."""
|
|
866
|
+
|
|
867
|
+
@abstractmethod
|
|
868
|
+
def create_session(
|
|
869
|
+
self,
|
|
870
|
+
session_id: str,
|
|
871
|
+
app_name: str,
|
|
872
|
+
user_id: str,
|
|
873
|
+
state: "dict[str, Any]",
|
|
874
|
+
owner_id: "Any | None" = None,
|
|
875
|
+
*,
|
|
876
|
+
app_state_delta: "dict[str, Any] | None" = None,
|
|
877
|
+
user_state_delta: "dict[str, Any] | None" = None,
|
|
878
|
+
) -> "StoredSession":
|
|
879
|
+
"""Create a new session and atomically merge any initial scoped state deltas."""
|
|
880
|
+
raise NotImplementedError
|
|
881
|
+
|
|
882
|
+
@abstractmethod
|
|
883
|
+
def get_session(
|
|
884
|
+
self, app_name: str, user_id: str, session_id: str, *, renew_for: "int | timedelta | None" = None
|
|
885
|
+
) -> "StoredSession | None":
|
|
886
|
+
"""Get a session.
|
|
887
|
+
|
|
888
|
+
Args:
|
|
889
|
+
app_name: Name of the application.
|
|
890
|
+
user_id: ID of the user.
|
|
891
|
+
session_id: Session identifier.
|
|
892
|
+
renew_for: If positive, touch the session update timestamp while reading.
|
|
893
|
+
|
|
894
|
+
Returns:
|
|
895
|
+
Session record if found, None otherwise.
|
|
896
|
+
"""
|
|
897
|
+
raise NotImplementedError
|
|
898
|
+
|
|
899
|
+
@abstractmethod
|
|
900
|
+
def update_session_state(self, app_name: str, user_id: str, session_id: str, state: "dict[str, Any]") -> None:
|
|
901
|
+
"""Update session state."""
|
|
902
|
+
raise NotImplementedError
|
|
903
|
+
|
|
904
|
+
@abstractmethod
|
|
905
|
+
def list_sessions(
|
|
906
|
+
self,
|
|
907
|
+
app_name: str,
|
|
908
|
+
user_id: "str | None" = None,
|
|
909
|
+
*,
|
|
910
|
+
order_by: "SessionOrderBy" = "update_time",
|
|
911
|
+
descending: bool = True,
|
|
912
|
+
limit: "int | None" = None,
|
|
913
|
+
offset: "int | None" = None,
|
|
914
|
+
) -> "list[StoredSession]":
|
|
915
|
+
"""List all sessions for an app, optionally filtered by user.
|
|
916
|
+
|
|
917
|
+
Args:
|
|
918
|
+
app_name: Name of the application.
|
|
919
|
+
user_id: ID of the user. If None, returns all sessions for the app.
|
|
920
|
+
order_by: Timestamp column to sort on.
|
|
921
|
+
descending: Sort direction applied to the timestamp column and the
|
|
922
|
+
``id`` tie-break.
|
|
923
|
+
limit: Maximum number of sessions to return. ``0`` returns an empty
|
|
924
|
+
list without database work.
|
|
925
|
+
offset: Number of leading rows to skip. Requires a finite limit
|
|
926
|
+
when positive.
|
|
927
|
+
|
|
928
|
+
Returns:
|
|
929
|
+
List of session records.
|
|
930
|
+
"""
|
|
931
|
+
raise NotImplementedError
|
|
932
|
+
|
|
933
|
+
@abstractmethod
|
|
934
|
+
def delete_session(self, app_name: str, user_id: str, session_id: str) -> None:
|
|
935
|
+
"""Delete a session and its events."""
|
|
936
|
+
raise NotImplementedError
|
|
937
|
+
|
|
938
|
+
@abstractmethod
|
|
939
|
+
def append_event(self, event_record: "StoredEvent") -> None:
|
|
940
|
+
"""Append an event to a session."""
|
|
941
|
+
raise NotImplementedError
|
|
942
|
+
|
|
943
|
+
@abstractmethod
|
|
944
|
+
def append_event_and_update_state(
|
|
945
|
+
self,
|
|
946
|
+
event_record: "StoredEvent",
|
|
947
|
+
app_name: str,
|
|
948
|
+
user_id: str,
|
|
949
|
+
session_id: str,
|
|
950
|
+
state: "dict[str, Any]",
|
|
951
|
+
*,
|
|
952
|
+
app_state_delta: "dict[str, Any] | None" = None,
|
|
953
|
+
user_state_delta: "dict[str, Any] | None" = None,
|
|
954
|
+
) -> "StoredSession":
|
|
955
|
+
"""Atomically append an event and merge session and scoped state deltas."""
|
|
956
|
+
raise NotImplementedError
|
|
957
|
+
|
|
958
|
+
@abstractmethod
|
|
959
|
+
def get_events(
|
|
960
|
+
self,
|
|
961
|
+
app_name: str,
|
|
962
|
+
user_id: str,
|
|
963
|
+
session_id: str,
|
|
964
|
+
after_timestamp: "datetime | None" = None,
|
|
965
|
+
limit: "int | None" = None,
|
|
966
|
+
) -> "list[StoredEvent]":
|
|
967
|
+
"""Get the most recent events for a session ordered chronologically."""
|
|
968
|
+
raise NotImplementedError
|
|
969
|
+
|
|
970
|
+
@abstractmethod
|
|
971
|
+
def delete_expired_events(self, before: datetime, app_name: "str | None" = None) -> int:
|
|
972
|
+
"""Delete events older than the given timestamp, optionally scoped to one application."""
|
|
973
|
+
raise NotImplementedError
|
|
974
|
+
|
|
975
|
+
@abstractmethod
|
|
976
|
+
def delete_idle_user_states(self, updated_before: datetime, app_name: "str | None" = None) -> int:
|
|
977
|
+
"""Delete user-scoped state rows whose update_time predates the threshold, optionally scoped to one application."""
|
|
978
|
+
raise NotImplementedError
|
|
979
|
+
|
|
980
|
+
@abstractmethod
|
|
981
|
+
def delete_idle_sessions(self, updated_before: datetime, app_name: "str | None" = None) -> int:
|
|
982
|
+
"""Delete sessions whose update_time predates the given threshold, optionally scoped to one application."""
|
|
983
|
+
raise NotImplementedError
|
|
984
|
+
|
|
985
|
+
@abstractmethod
|
|
986
|
+
def get_app_state(self, app_name: str) -> "dict[str, Any] | None":
|
|
987
|
+
"""Return app-scoped state for an application."""
|
|
988
|
+
raise NotImplementedError
|
|
989
|
+
|
|
990
|
+
@abstractmethod
|
|
991
|
+
def get_user_state(self, app_name: str, user_id: str) -> "dict[str, Any] | None":
|
|
992
|
+
"""Return user-scoped state for an application user."""
|
|
993
|
+
raise NotImplementedError
|
|
994
|
+
|
|
995
|
+
@abstractmethod
|
|
996
|
+
def upsert_app_state(self, app_name: str, state: "dict[str, Any]") -> None:
|
|
997
|
+
"""Insert or replace app-scoped state for an application."""
|
|
998
|
+
raise NotImplementedError
|
|
999
|
+
|
|
1000
|
+
@abstractmethod
|
|
1001
|
+
def upsert_user_state(self, app_name: str, user_id: str, state: "dict[str, Any]") -> None:
|
|
1002
|
+
"""Insert or replace user-scoped state for an application user."""
|
|
1003
|
+
raise NotImplementedError
|
|
1004
|
+
|
|
1005
|
+
@abstractmethod
|
|
1006
|
+
def get_metadata(self, key: str) -> "str | None":
|
|
1007
|
+
"""Return a value from the ADK internal metadata table."""
|
|
1008
|
+
raise NotImplementedError
|
|
1009
|
+
|
|
1010
|
+
@abstractmethod
|
|
1011
|
+
def set_metadata(self, key: str, value: str) -> None:
|
|
1012
|
+
"""Set a value in the ADK internal metadata table."""
|
|
1013
|
+
raise NotImplementedError
|
|
1014
|
+
|
|
1015
|
+
def reconcile_schema(self, *, assume_existing: bool = False) -> None:
|
|
1016
|
+
"""Apply additive ADK table changes from canonical adapter DDL.
|
|
1017
|
+
|
|
1018
|
+
Args:
|
|
1019
|
+
assume_existing: Skip table discovery after adapter-level creation.
|
|
1020
|
+
"""
|
|
1021
|
+
manage_schema, create_schema = self._schema_management_flags()
|
|
1022
|
+
if not manage_schema:
|
|
1023
|
+
return
|
|
1024
|
+
targets = self._schema_targets()
|
|
1025
|
+
_reconcile_adk_schema_sync(self._config, targets, create_schema=create_schema, assume_existing=assume_existing)
|
|
1026
|
+
|
|
1027
|
+
def ensure_tables(self) -> None:
|
|
1028
|
+
"""Create tables and emit a standardized log entry."""
|
|
1029
|
+
|
|
1030
|
+
if self.create_schema_enabled:
|
|
1031
|
+
self.create_tables()
|
|
1032
|
+
self.reconcile_schema(assume_existing=self.create_schema_enabled)
|
|
1033
|
+
self._log_tables_created()
|
|
1034
|
+
|
|
1035
|
+
def drop_tables(self) -> None:
|
|
1036
|
+
"""Drop all ADK tables managed by this store in FK-safe order."""
|
|
1037
|
+
self._execute_lifecycle_scripts(self._drop_tables_sql())
|
|
1038
|
+
self._log_tables_dropped()
|
|
1039
|
+
|
|
1040
|
+
def recreate_tables(self) -> None:
|
|
1041
|
+
"""Drop and recreate all ADK tables managed by this store."""
|
|
1042
|
+
self.drop_tables()
|
|
1043
|
+
self.ensure_tables()
|
|
1044
|
+
self._log_tables_recreated()
|
|
1045
|
+
|
|
1046
|
+
def _schema_targets(self) -> "list[SchemaTarget]":
|
|
1047
|
+
"""Construct SchemaTarget definitions for all ADK session tables."""
|
|
1048
|
+
statement_config = getattr(self._config, "statement_config", None)
|
|
1049
|
+
dialect = getattr(statement_config, "dialect", None)
|
|
1050
|
+
ddl_targets = (
|
|
1051
|
+
(self._session_table, self._sessions_table_ddl()),
|
|
1052
|
+
(self._events_table, self._events_table_ddl()),
|
|
1053
|
+
(self._app_state_table, self._app_states_table_ddl()),
|
|
1054
|
+
(self._user_state_table, self._user_states_table_ddl()),
|
|
1055
|
+
(self._metadata_table, self._metadata_table_ddl()),
|
|
1056
|
+
)
|
|
1057
|
+
return [SchemaTarget.from_ddl(table, ddl, dialect=dialect) for table, ddl in ddl_targets]
|
|
1058
|
+
|
|
1059
|
+
def _execute_lifecycle_scripts(self, statements: list[str]) -> None:
|
|
1060
|
+
"""Execute lifecycle DDL scripts using the sync driver session."""
|
|
1061
|
+
_run_lifecycle_sync(self._config, statements)
|
|
1062
|
+
|
|
1063
|
+
@abstractmethod
|
|
1064
|
+
def _sessions_table_ddl(self) -> str:
|
|
1065
|
+
"""Get the CREATE TABLE SQL for the sessions table."""
|
|
1066
|
+
raise NotImplementedError
|
|
1067
|
+
|
|
1068
|
+
@abstractmethod
|
|
1069
|
+
def _events_table_ddl(self) -> str:
|
|
1070
|
+
"""Get the CREATE TABLE SQL for the events table."""
|
|
1071
|
+
raise NotImplementedError
|
|
1072
|
+
|
|
1073
|
+
@abstractmethod
|
|
1074
|
+
def _app_states_table_ddl(self) -> str:
|
|
1075
|
+
"""Get the CREATE TABLE SQL for the app-scoped state table."""
|
|
1076
|
+
raise NotImplementedError
|
|
1077
|
+
|
|
1078
|
+
@abstractmethod
|
|
1079
|
+
def _user_states_table_ddl(self) -> str:
|
|
1080
|
+
"""Get the CREATE TABLE SQL for the user-scoped state table."""
|
|
1081
|
+
raise NotImplementedError
|
|
1082
|
+
|
|
1083
|
+
@abstractmethod
|
|
1084
|
+
def _metadata_table_ddl(self) -> str:
|
|
1085
|
+
"""Get the CREATE TABLE SQL for the ADK internal metadata table."""
|
|
1086
|
+
raise NotImplementedError
|
|
1087
|
+
|
|
1088
|
+
@abstractmethod
|
|
1089
|
+
def _drop_app_states_table_sql(self) -> str:
|
|
1090
|
+
"""Get the DROP TABLE SQL statement for the app-scoped state table."""
|
|
1091
|
+
raise NotImplementedError
|
|
1092
|
+
|
|
1093
|
+
@abstractmethod
|
|
1094
|
+
def _drop_user_states_table_sql(self) -> str:
|
|
1095
|
+
"""Get the DROP TABLE SQL statement for the user-scoped state table."""
|
|
1096
|
+
raise NotImplementedError
|
|
1097
|
+
|
|
1098
|
+
@abstractmethod
|
|
1099
|
+
def _drop_metadata_table_sql(self) -> str:
|
|
1100
|
+
"""Get the DROP TABLE SQL statement for the ADK internal metadata table."""
|
|
1101
|
+
raise NotImplementedError
|
|
1102
|
+
|
|
1103
|
+
@abstractmethod
|
|
1104
|
+
def _drop_tables_sql(self) -> "list[str]":
|
|
1105
|
+
"""Get the DROP TABLE SQL statements for this database dialect."""
|
|
1106
|
+
raise NotImplementedError
|
|
1107
|
+
|
|
1108
|
+
def _reset_drop_tables_sql(self) -> "list[str]":
|
|
1109
|
+
"""Return the drops that remove configured and legacy ADK session tables."""
|
|
1110
|
+
return self._reset_drop_statements()
|
|
1111
|
+
|
|
1112
|
+
def _provide_replica_connection(self, *, primary: bool = False, **kwargs: Any) -> AbstractContextManager[Any]:
|
|
1113
|
+
return cast("AbstractContextManager[Any]", super()._provide_replica_connection(primary=primary, **kwargs))
|
|
1114
|
+
|
|
1115
|
+
def _provide_replica_session(self, *, primary: bool = False, **kwargs: Any) -> AbstractContextManager[Any]:
|
|
1116
|
+
return cast("AbstractContextManager[Any]", super()._provide_replica_session(primary=primary, **kwargs))
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
def normalize_session_list_options(
|
|
1120
|
+
order_by: "SessionOrderBy" = "update_time",
|
|
1121
|
+
descending: bool = True,
|
|
1122
|
+
limit: "int | None" = None,
|
|
1123
|
+
offset: "int | None" = None,
|
|
1124
|
+
) -> "tuple[SessionOrderBy, str, int | None, int]":
|
|
1125
|
+
"""Validate session listing options and resolve their ordering parts.
|
|
1126
|
+
|
|
1127
|
+
Args:
|
|
1128
|
+
order_by: Timestamp column to sort on. Only ``create_time`` and
|
|
1129
|
+
``update_time`` are accepted.
|
|
1130
|
+
descending: Sort direction applied to both the timestamp column and the
|
|
1131
|
+
``id`` tie-break.
|
|
1132
|
+
limit: Maximum number of sessions to return, or ``None`` for an
|
|
1133
|
+
unbounded listing.
|
|
1134
|
+
offset: Number of leading rows to skip. ``None`` is equivalent to zero.
|
|
1135
|
+
|
|
1136
|
+
Returns:
|
|
1137
|
+
The allowlisted order column, the ``ASC``/``DESC`` direction keyword,
|
|
1138
|
+
the validated limit, and the normalized offset. Callers render the
|
|
1139
|
+
``ORDER BY`` body in whichever form their driver accepts.
|
|
1140
|
+
|
|
1141
|
+
Raises:
|
|
1142
|
+
ValueError: If the order column is outside the allowlist, a page bound
|
|
1143
|
+
is a boolean or a negative integer, or a positive offset is
|
|
1144
|
+
combined with an unbounded limit.
|
|
1145
|
+
"""
|
|
1146
|
+
if order_by not in SESSION_ORDER_COLUMNS:
|
|
1147
|
+
msg = f"order_by must be one of {SESSION_ORDER_COLUMNS}, got {order_by!r}"
|
|
1148
|
+
raise ValueError(msg)
|
|
1149
|
+
if limit is not None and (isinstance(limit, bool) or not isinstance(limit, int) or limit < 0):
|
|
1150
|
+
msg = f"limit must be a non-negative integer or None, got {limit!r}"
|
|
1151
|
+
raise ValueError(msg)
|
|
1152
|
+
if offset is not None and (isinstance(offset, bool) or not isinstance(offset, int) or offset < 0):
|
|
1153
|
+
msg = f"offset must be a non-negative integer or None, got {offset!r}"
|
|
1154
|
+
raise ValueError(msg)
|
|
1155
|
+
|
|
1156
|
+
normalized_offset = 0 if offset is None else offset
|
|
1157
|
+
if normalized_offset > 0 and limit is None:
|
|
1158
|
+
msg = "offset requires a limit; unbounded offset is not supported"
|
|
1159
|
+
raise ValueError(msg)
|
|
1160
|
+
|
|
1161
|
+
return order_by, "DESC" if descending else "ASC", limit, normalized_offset
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
def _run_lifecycle_sync(config: Any, statements: "list[str]") -> None:
|
|
1165
|
+
"""Execute lifecycle statements through a synchronous config session."""
|
|
1166
|
+
with cast("Any", config.provide_session()) as driver:
|
|
1167
|
+
for statement in statements:
|
|
1168
|
+
driver.execute_script(statement)
|
|
1169
|
+
commit = getattr(driver, "commit", None)
|
|
1170
|
+
if callable(commit):
|
|
1171
|
+
commit()
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
def _reconcile_adk_schema_sync(
|
|
1175
|
+
config: Any, targets: "list[SchemaTarget]", *, create_schema: bool, assume_existing: bool
|
|
1176
|
+
) -> None:
|
|
1177
|
+
"""Run additive reconciliation for a synchronous ADK store."""
|
|
1178
|
+
with cast("Any", config.provide_session()) as driver:
|
|
1179
|
+
ensure_schema_sync(
|
|
1180
|
+
driver, targets, manage_schema=True, create_schema=create_schema, assume_existing=assume_existing
|
|
1181
|
+
)
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
def _resolve_adk_read_settings(
|
|
1185
|
+
config: "DatabaseConfigProtocol[Any, Any, Any]", read_config: "DatabaseConfigProtocol[Any, Any, Any] | None"
|
|
1186
|
+
) -> tuple[bool, str | None]:
|
|
1187
|
+
settings = config.extension_config.get("adk", {})
|
|
1188
|
+
default_replica_group = settings.get("default_replica_group")
|
|
1189
|
+
if default_replica_group is not None and (
|
|
1190
|
+
not isinstance(default_replica_group, str) or not is_valid_routing_token(default_replica_group)
|
|
1191
|
+
):
|
|
1192
|
+
msg = "ADK default_replica_group must be None or a non-empty printable string of at most 256 characters"
|
|
1193
|
+
raise ImproperConfigurationError(msg)
|
|
1194
|
+
enabled = settings.get("enable_replica_reads", read_config is not None or default_replica_group is not None)
|
|
1195
|
+
if not isinstance(enabled, bool):
|
|
1196
|
+
msg = "ADK enable_replica_reads must be a boolean"
|
|
1197
|
+
raise ImproperConfigurationError(msg)
|
|
1198
|
+
if read_config is not None and (
|
|
1199
|
+
config.is_async != read_config.is_async or resolve_adapter_name(config) != resolve_adapter_name(read_config)
|
|
1200
|
+
):
|
|
1201
|
+
msg = "ADK reader configuration must use the same adapter and execution mode as the primary"
|
|
1202
|
+
raise ImproperConfigurationError(msg)
|
|
1203
|
+
return enabled, default_replica_group
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
def _provide_adk_read_context(
|
|
1207
|
+
config: "DatabaseConfigProtocol[Any, Any, Any]",
|
|
1208
|
+
read_config: "DatabaseConfigProtocol[Any, Any, Any] | None",
|
|
1209
|
+
enabled: bool,
|
|
1210
|
+
default_replica_group: str | None,
|
|
1211
|
+
primary: bool,
|
|
1212
|
+
session: bool,
|
|
1213
|
+
kwargs: dict[str, Any],
|
|
1214
|
+
) -> AbstractContextManager[Any] | AbstractAsyncContextManager[Any]:
|
|
1215
|
+
if primary or not enabled or _ADK_PRIMARY_READ.get():
|
|
1216
|
+
return config.provide_session(**kwargs) if session else config.provide_connection(**kwargs)
|
|
1217
|
+
entry = RoutingContext.get_entry(config.bind_key)
|
|
1218
|
+
if entry is not None and (entry.mode == "primary" or entry.pinned_by_write):
|
|
1219
|
+
return config.provide_session(**kwargs) if session else config.provide_connection(**kwargs)
|
|
1220
|
+
if read_config is not None:
|
|
1221
|
+
return read_config.provide_session(**kwargs) if session else read_config.provide_connection(**kwargs)
|
|
1222
|
+
call_kwargs = dict(kwargs)
|
|
1223
|
+
explicit_group = call_kwargs.pop("replica_group", None)
|
|
1224
|
+
effective_group = (
|
|
1225
|
+
explicit_group
|
|
1226
|
+
if explicit_group is not None
|
|
1227
|
+
else entry.replica_group
|
|
1228
|
+
if entry is not None and entry.replica_group is not None
|
|
1229
|
+
else default_replica_group
|
|
1230
|
+
)
|
|
1231
|
+
if effective_group is not None:
|
|
1232
|
+
return (
|
|
1233
|
+
config.provide_replica_session(replica_group=effective_group, **call_kwargs)
|
|
1234
|
+
if session
|
|
1235
|
+
else config.provide_replica_connection(replica_group=effective_group, **call_kwargs)
|
|
1236
|
+
)
|
|
1237
|
+
return (
|
|
1238
|
+
config.provide_replica_session(**call_kwargs) if session else config.provide_replica_connection(**call_kwargs)
|
|
1239
|
+
)
|