sqlspec 0.72.0__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 6b29784d6b1cafc66758__mypyc.cp315-win_amd64.pyd +0 -0
- sqlspec/__init__.py +381 -0
- sqlspec/__main__.py +14 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_typing.py +775 -0
- sqlspec/adapters/__init__.py +3 -0
- sqlspec/adapters/adbc/__init__.py +16 -0
- sqlspec/adapters/adbc/_typing.py +221 -0
- sqlspec/adapters/adbc/adk/__init__.py +11 -0
- sqlspec/adapters/adbc/adk/store.py +4101 -0
- sqlspec/adapters/adbc/config.py +843 -0
- sqlspec/adapters/adbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/core.py +3209 -0
- sqlspec/adapters/adbc/data_dictionary.py +1448 -0
- sqlspec/adapters/adbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/driver.py +1400 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +384 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +962 -0
- sqlspec/adapters/adbc/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/pool.py +242 -0
- sqlspec/adapters/adbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/type_converter.py +117 -0
- sqlspec/adapters/aiomysql/__init__.py +25 -0
- sqlspec/adapters/aiomysql/_typing.py +134 -0
- sqlspec/adapters/aiomysql/adk/__init__.py +5 -0
- sqlspec/adapters/aiomysql/adk/store.py +1542 -0
- sqlspec/adapters/aiomysql/config.py +634 -0
- sqlspec/adapters/aiomysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/core.py +922 -0
- sqlspec/adapters/aiomysql/data_dictionary.py +16 -0
- sqlspec/adapters/aiomysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/driver.py +494 -0
- sqlspec/adapters/aiomysql/events/__init__.py +5 -0
- sqlspec/adapters/aiomysql/events/store.py +72 -0
- sqlspec/adapters/aiomysql/litestar/__init__.py +5 -0
- sqlspec/adapters/aiomysql/litestar/store.py +345 -0
- sqlspec/adapters/aiosqlite/__init__.py +43 -0
- sqlspec/adapters/aiosqlite/_typing.py +75 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +1546 -0
- sqlspec/adapters/aiosqlite/config.py +607 -0
- sqlspec/adapters/aiosqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/core.py +1155 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +343 -0
- sqlspec/adapters/aiosqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/driver.py +559 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +54 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +315 -0
- sqlspec/adapters/aiosqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/pool.py +1323 -0
- sqlspec/adapters/aiosqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/type_converter.py +114 -0
- sqlspec/adapters/arrow_odbc/__init__.py +32 -0
- sqlspec/adapters/arrow_odbc/_typing.py +131 -0
- sqlspec/adapters/arrow_odbc/adk/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/adk/store.py +1671 -0
- sqlspec/adapters/arrow_odbc/config.py +446 -0
- sqlspec/adapters/arrow_odbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/core.py +795 -0
- sqlspec/adapters/arrow_odbc/data_dictionary.py +345 -0
- sqlspec/adapters/arrow_odbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/driver.py +885 -0
- sqlspec/adapters/arrow_odbc/events/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/events/store.py +114 -0
- sqlspec/adapters/arrow_odbc/litestar/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/litestar/store.py +682 -0
- sqlspec/adapters/arrow_odbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/type_converter.py +95 -0
- sqlspec/adapters/asyncmy/__init__.py +27 -0
- sqlspec/adapters/asyncmy/_typing.py +215 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +1544 -0
- sqlspec/adapters/asyncmy/config.py +707 -0
- sqlspec/adapters/asyncmy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/core.py +917 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +16 -0
- sqlspec/adapters/asyncmy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/driver.py +529 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +72 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +348 -0
- sqlspec/adapters/asyncpg/__init__.py +28 -0
- sqlspec/adapters/asyncpg/_typing.py +113 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +1145 -0
- sqlspec/adapters/asyncpg/config.py +903 -0
- sqlspec/adapters/asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/core.py +797 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +417 -0
- sqlspec/adapters/asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/driver.py +927 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/events/_hub.py +279 -0
- sqlspec/adapters/asyncpg/events/backend.py +410 -0
- sqlspec/adapters/asyncpg/events/store.py +57 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +278 -0
- sqlspec/adapters/asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/tenant.py +140 -0
- sqlspec/adapters/bigquery/__init__.py +23 -0
- sqlspec/adapters/bigquery/_typing.py +184 -0
- sqlspec/adapters/bigquery/adk/__init__.py +5 -0
- sqlspec/adapters/bigquery/adk/store.py +920 -0
- sqlspec/adapters/bigquery/config.py +631 -0
- sqlspec/adapters/bigquery/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/core.py +1433 -0
- sqlspec/adapters/bigquery/data_dictionary.py +502 -0
- sqlspec/adapters/bigquery/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/driver.py +1266 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +158 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +359 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +32 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +54 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +9 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +1096 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +653 -0
- sqlspec/adapters/cockroach_asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +835 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +371 -0
- sqlspec/adapters/cockroach_asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +438 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +203 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.py +143 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +46 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +271 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +2274 -0
- sqlspec/adapters/cockroach_psycopg/config.py +1285 -0
- sqlspec/adapters/cockroach_psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +667 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +622 -0
- sqlspec/adapters/cockroach_psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +864 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +8 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +9 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +413 -0
- sqlspec/adapters/cockroach_psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/tenant.py +222 -0
- sqlspec/adapters/db2/__init__.py +34 -0
- sqlspec/adapters/db2/_typing.py +357 -0
- sqlspec/adapters/db2/adk/__init__.py +10 -0
- sqlspec/adapters/db2/adk/store.py +1950 -0
- sqlspec/adapters/db2/config.py +550 -0
- sqlspec/adapters/db2/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/core.py +1021 -0
- sqlspec/adapters/db2/data_dictionary.py +493 -0
- sqlspec/adapters/db2/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/driver.py +898 -0
- sqlspec/adapters/db2/events/__init__.py +5 -0
- sqlspec/adapters/db2/events/store.py +77 -0
- sqlspec/adapters/db2/litestar/__init__.py +5 -0
- sqlspec/adapters/db2/litestar/store.py +519 -0
- sqlspec/adapters/db2/migrations.py +221 -0
- sqlspec/adapters/db2/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/pool.py +876 -0
- sqlspec/adapters/db2/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/tenant.py +292 -0
- sqlspec/adapters/duckdb/__init__.py +30 -0
- sqlspec/adapters/duckdb/_typing.py +182 -0
- sqlspec/adapters/duckdb/adk/__init__.py +10 -0
- sqlspec/adapters/duckdb/adk/store.py +1672 -0
- sqlspec/adapters/duckdb/config.py +506 -0
- sqlspec/adapters/duckdb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/core.py +1299 -0
- sqlspec/adapters/duckdb/data_dictionary.py +553 -0
- sqlspec/adapters/duckdb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/driver.py +1214 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +38 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +313 -0
- sqlspec/adapters/duckdb/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/pool.py +1121 -0
- sqlspec/adapters/mssql_python/__init__.py +42 -0
- sqlspec/adapters/mssql_python/_typing.py +135 -0
- sqlspec/adapters/mssql_python/adk/__init__.py +5 -0
- sqlspec/adapters/mssql_python/adk/store.py +1278 -0
- sqlspec/adapters/mssql_python/config.py +455 -0
- sqlspec/adapters/mssql_python/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/core.py +862 -0
- sqlspec/adapters/mssql_python/data_dictionary.py +417 -0
- sqlspec/adapters/mssql_python/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/driver.py +772 -0
- sqlspec/adapters/mssql_python/events/__init__.py +5 -0
- sqlspec/adapters/mssql_python/events/store.py +46 -0
- sqlspec/adapters/mssql_python/litestar/__init__.py +5 -0
- sqlspec/adapters/mssql_python/litestar/store.py +355 -0
- sqlspec/adapters/mssql_python/migrations.py +162 -0
- sqlspec/adapters/mssql_python/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/pool.py +165 -0
- sqlspec/adapters/mssql_python/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/tenant.py +74 -0
- sqlspec/adapters/mssql_python/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/type_converter.py +98 -0
- sqlspec/adapters/mysqlconnector/__init__.py +47 -0
- sqlspec/adapters/mysqlconnector/_typing.py +205 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +17 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +2503 -0
- sqlspec/adapters/mysqlconnector/config.py +925 -0
- sqlspec/adapters/mysqlconnector/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/core.py +1075 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +23 -0
- sqlspec/adapters/mysqlconnector/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/driver.py +702 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +89 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +9 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +524 -0
- sqlspec/adapters/oracledb/__init__.py +159 -0
- sqlspec/adapters/oracledb/_json_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_json_handlers.py +208 -0
- sqlspec/adapters/oracledb/_param_types.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_param_types.py +65 -0
- sqlspec/adapters/oracledb/_plugins.py +137 -0
- sqlspec/adapters/oracledb/_storage.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_storage.py +138 -0
- sqlspec/adapters/oracledb/_typing.py +468 -0
- sqlspec/adapters/oracledb/_uuid_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +143 -0
- sqlspec/adapters/oracledb/_vector_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_vector_handlers.py +252 -0
- sqlspec/adapters/oracledb/adk/__init__.py +27 -0
- sqlspec/adapters/oracledb/adk/store.py +4031 -0
- sqlspec/adapters/oracledb/config.py +1785 -0
- sqlspec/adapters/oracledb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/core.py +5416 -0
- sqlspec/adapters/oracledb/data_dictionary.py +1264 -0
- sqlspec/adapters/oracledb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/driver.py +3273 -0
- sqlspec/adapters/oracledb/events/__init__.py +29 -0
- sqlspec/adapters/oracledb/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/events/_hub.py +394 -0
- sqlspec/adapters/oracledb/events/backend.py +311 -0
- sqlspec/adapters/oracledb/events/store.py +842 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +17 -0
- sqlspec/adapters/oracledb/litestar/store.py +862 -0
- sqlspec/adapters/oracledb/migrations.py +650 -0
- sqlspec/adapters/oracledb/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/tenant.py +990 -0
- sqlspec/adapters/oracledb/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/type_converter.py +93 -0
- sqlspec/adapters/psqlpy/__init__.py +21 -0
- sqlspec/adapters/psqlpy/_typing.py +180 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +1514 -0
- sqlspec/adapters/psqlpy/config.py +828 -0
- sqlspec/adapters/psqlpy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/core.py +1040 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +399 -0
- sqlspec/adapters/psqlpy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/driver.py +631 -0
- sqlspec/adapters/psqlpy/events/__init__.py +12 -0
- sqlspec/adapters/psqlpy/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/events/_hub.py +367 -0
- sqlspec/adapters/psqlpy/events/backend.py +415 -0
- sqlspec/adapters/psqlpy/events/store.py +46 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/tenant.py +137 -0
- sqlspec/adapters/psqlpy/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +21 -0
- sqlspec/adapters/psycopg/__init__.py +44 -0
- sqlspec/adapters/psycopg/_typing.py +408 -0
- sqlspec/adapters/psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/psycopg/adk/store.py +2761 -0
- sqlspec/adapters/psycopg/config.py +1522 -0
- sqlspec/adapters/psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/core.py +1001 -0
- sqlspec/adapters/psycopg/data_dictionary.py +701 -0
- sqlspec/adapters/psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/driver.py +1629 -0
- sqlspec/adapters/psycopg/events/__init__.py +25 -0
- sqlspec/adapters/psycopg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/events/_hub.py +646 -0
- sqlspec/adapters/psycopg/events/backend.py +739 -0
- sqlspec/adapters/psycopg/events/store.py +82 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +595 -0
- sqlspec/adapters/psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/tenant.py +226 -0
- sqlspec/adapters/psycopg/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/type_converter.py +94 -0
- sqlspec/adapters/pymssql/__init__.py +29 -0
- sqlspec/adapters/pymssql/_typing.py +156 -0
- sqlspec/adapters/pymssql/adk/__init__.py +5 -0
- sqlspec/adapters/pymssql/adk/store.py +1270 -0
- sqlspec/adapters/pymssql/config.py +299 -0
- sqlspec/adapters/pymssql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/core.py +527 -0
- sqlspec/adapters/pymssql/data_dictionary.py +417 -0
- sqlspec/adapters/pymssql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/driver.py +527 -0
- sqlspec/adapters/pymssql/events/__init__.py +5 -0
- sqlspec/adapters/pymssql/events/store.py +46 -0
- sqlspec/adapters/pymssql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymssql/litestar/store.py +350 -0
- sqlspec/adapters/pymssql/migrations.py +162 -0
- sqlspec/adapters/pymssql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/pool.py +417 -0
- sqlspec/adapters/pymssql/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/tenant.py +73 -0
- sqlspec/adapters/pymysql/__init__.py +27 -0
- sqlspec/adapters/pymysql/_typing.py +105 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +1646 -0
- sqlspec/adapters/pymysql/config.py +545 -0
- sqlspec/adapters/pymysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/core.py +909 -0
- sqlspec/adapters/pymysql/data_dictionary.py +16 -0
- sqlspec/adapters/pymysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/driver.py +370 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +42 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +299 -0
- sqlspec/adapters/pymysql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/pool.py +480 -0
- sqlspec/adapters/snowflake/__init__.py +36 -0
- sqlspec/adapters/snowflake/_typing.py +62 -0
- sqlspec/adapters/snowflake/adk/__init__.py +5 -0
- sqlspec/adapters/snowflake/adk/store.py +778 -0
- sqlspec/adapters/snowflake/config.py +333 -0
- sqlspec/adapters/snowflake/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/core.py +683 -0
- sqlspec/adapters/snowflake/data_dictionary.py +355 -0
- sqlspec/adapters/snowflake/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/driver.py +872 -0
- sqlspec/adapters/snowflake/events/__init__.py +5 -0
- sqlspec/adapters/snowflake/events/store.py +28 -0
- sqlspec/adapters/snowflake/litestar/__init__.py +5 -0
- sqlspec/adapters/snowflake/litestar/store.py +162 -0
- sqlspec/adapters/snowflake/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/migrations.py +76 -0
- sqlspec/adapters/snowflake/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/pool.py +385 -0
- sqlspec/adapters/snowflake/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/tenant.py +200 -0
- sqlspec/adapters/snowflake/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/type_converter.py +33 -0
- sqlspec/adapters/spanner/__init__.py +57 -0
- sqlspec/adapters/spanner/_typing.py +300 -0
- sqlspec/adapters/spanner/adk/__init__.py +22 -0
- sqlspec/adapters/spanner/adk/artifact_store.py +693 -0
- sqlspec/adapters/spanner/adk/store.py +3053 -0
- sqlspec/adapters/spanner/config.py +1578 -0
- sqlspec/adapters/spanner/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/core.py +1244 -0
- sqlspec/adapters/spanner/data_dictionary.py +706 -0
- sqlspec/adapters/spanner/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/driver.py +1673 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +357 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +570 -0
- sqlspec/adapters/spanner/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/type_converter.py +466 -0
- sqlspec/adapters/sqlanywhere/__init__.py +40 -0
- sqlspec/adapters/sqlanywhere/_typing.py +139 -0
- sqlspec/adapters/sqlanywhere/adk/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/adk/store.py +1136 -0
- sqlspec/adapters/sqlanywhere/config.py +359 -0
- sqlspec/adapters/sqlanywhere/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/core.py +583 -0
- sqlspec/adapters/sqlanywhere/data_dictionary.py +282 -0
- sqlspec/adapters/sqlanywhere/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/driver.py +480 -0
- sqlspec/adapters/sqlanywhere/events/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/events/store.py +28 -0
- sqlspec/adapters/sqlanywhere/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/litestar/store.py +237 -0
- sqlspec/adapters/sqlanywhere/migrations.py +178 -0
- sqlspec/adapters/sqlanywhere/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/pool.py +397 -0
- sqlspec/adapters/sqlite/__init__.py +32 -0
- sqlspec/adapters/sqlite/_typing.py +91 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +1628 -0
- sqlspec/adapters/sqlite/config.py +520 -0
- sqlspec/adapters/sqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/core.py +1035 -0
- sqlspec/adapters/sqlite/data_dictionary.py +327 -0
- sqlspec/adapters/sqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/driver.py +432 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +54 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +367 -0
- sqlspec/adapters/sqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/pool.py +935 -0
- sqlspec/adapters/sqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/adapters/sybase/__init__.py +37 -0
- sqlspec/adapters/sybase/_typing.py +150 -0
- sqlspec/adapters/sybase/adk/__init__.py +5 -0
- sqlspec/adapters/sybase/adk/store.py +1370 -0
- sqlspec/adapters/sybase/config.py +276 -0
- sqlspec/adapters/sybase/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/core.py +578 -0
- sqlspec/adapters/sybase/data_dictionary.py +358 -0
- sqlspec/adapters/sybase/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/driver.py +497 -0
- sqlspec/adapters/sybase/events/__init__.py +5 -0
- sqlspec/adapters/sybase/events/store.py +88 -0
- sqlspec/adapters/sybase/litestar/__init__.py +5 -0
- sqlspec/adapters/sybase/litestar/store.py +328 -0
- sqlspec/adapters/sybase/migrations.py +178 -0
- sqlspec/adapters/sybase/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/pool.py +435 -0
- sqlspec/adapters/teradata/__init__.py +59 -0
- sqlspec/adapters/teradata/_typing.py +145 -0
- sqlspec/adapters/teradata/adk/__init__.py +5 -0
- sqlspec/adapters/teradata/adk/store.py +1300 -0
- sqlspec/adapters/teradata/config.py +324 -0
- sqlspec/adapters/teradata/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/core.py +437 -0
- sqlspec/adapters/teradata/data_dictionary.py +316 -0
- sqlspec/adapters/teradata/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/driver.py +721 -0
- sqlspec/adapters/teradata/events/__init__.py +5 -0
- sqlspec/adapters/teradata/events/store.py +64 -0
- sqlspec/adapters/teradata/litestar/__init__.py +5 -0
- sqlspec/adapters/teradata/litestar/store.py +264 -0
- sqlspec/adapters/teradata/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/migrations.py +80 -0
- sqlspec/adapters/teradata/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/pool.py +377 -0
- sqlspec/adapters/teradata/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/type_converter.py +95 -0
- sqlspec/base.cp315-win_amd64.pyd +0 -0
- sqlspec/base.py +1275 -0
- sqlspec/builder/__init__.py +330 -0
- sqlspec/builder/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_base.py +1752 -0
- sqlspec/builder/_column.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_column.py +508 -0
- sqlspec/builder/_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_ddl.py +4503 -0
- sqlspec/builder/_delete.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_delete.py +75 -0
- sqlspec/builder/_dml.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_dml.py +639 -0
- sqlspec/builder/_explain.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_explain.py +650 -0
- sqlspec/builder/_expression_wrappers.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_expression_wrappers.py +77 -0
- sqlspec/builder/_factory.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_factory.py +1834 -0
- sqlspec/builder/_generation.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_generation.py +55 -0
- sqlspec/builder/_insert.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_insert.py +308 -0
- sqlspec/builder/_join.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_join.py +501 -0
- sqlspec/builder/_locking.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_locking.py +77 -0
- sqlspec/builder/_merge.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_merge.py +1047 -0
- sqlspec/builder/_parsing_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_parsing_utils.py +1197 -0
- sqlspec/builder/_select.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_select.py +1514 -0
- sqlspec/builder/_temporal.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_temporal.py +183 -0
- sqlspec/builder/_update.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_update.py +139 -0
- sqlspec/builder/_values.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_values.py +271 -0
- sqlspec/builder/_vector_distance.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_vector_distance.py +763 -0
- sqlspec/cli.py +1656 -0
- sqlspec/config.py +3402 -0
- sqlspec/core/__init__.py +542 -0
- sqlspec/core/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_cursor.py +564 -0
- sqlspec/core/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_operators.py +167 -0
- sqlspec/core/_ordering.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_ordering.py +151 -0
- sqlspec/core/_pagination.py +66 -0
- sqlspec/core/_pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pipeline.py +343 -0
- sqlspec/core/_pool.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pool.py +72 -0
- sqlspec/core/cache.cp315-win_amd64.pyd +0 -0
- sqlspec/core/cache.py +1503 -0
- sqlspec/core/capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/core/capabilities.py +67 -0
- sqlspec/core/compiler.cp315-win_amd64.pyd +0 -0
- sqlspec/core/compiler.py +1667 -0
- sqlspec/core/config_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/core/config_runtime.py +219 -0
- sqlspec/core/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/core/correlation.py +135 -0
- sqlspec/core/explain.cp315-win_amd64.pyd +0 -0
- sqlspec/core/explain.py +284 -0
- sqlspec/core/filters.cp315-win_amd64.pyd +0 -0
- sqlspec/core/filters.py +1442 -0
- sqlspec/core/hashing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/hashing.py +394 -0
- sqlspec/core/metrics.cp315-win_amd64.pyd +0 -0
- sqlspec/core/metrics.py +86 -0
- sqlspec/core/parameters/__init__.py +174 -0
- sqlspec/core/parameters/_alignment.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_alignment.py +321 -0
- sqlspec/core/parameters/_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_converter.py +956 -0
- sqlspec/core/parameters/_declared.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_declared.py +154 -0
- sqlspec/core/parameters/_processor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_processor.py +1646 -0
- sqlspec/core/parameters/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_registry.py +207 -0
- sqlspec/core/parameters/_transformers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_transformers.py +318 -0
- sqlspec/core/parameters/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_types.py +658 -0
- sqlspec/core/parameters/_validator.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_validator.py +699 -0
- sqlspec/core/query_modifiers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/query_modifiers.py +559 -0
- sqlspec/core/result/__init__.py +67 -0
- sqlspec/core/result/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/result/_base.py +1772 -0
- sqlspec/core/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/routing.py +270 -0
- sqlspec/core/splitter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/splitter.py +1126 -0
- sqlspec/core/sqlcommenter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/sqlcommenter.py +509 -0
- sqlspec/core/stack.cp315-win_amd64.pyd +0 -0
- sqlspec/core/stack.py +167 -0
- sqlspec/core/statement.cp315-win_amd64.pyd +0 -0
- sqlspec/core/statement.py +2253 -0
- sqlspec/core/tenant/__init__.py +64 -0
- sqlspec/core/tenant/base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/tenant/base.py +123 -0
- sqlspec/core/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/type_converter.py +147 -0
- sqlspec/data_dictionary/__init__.py +237 -0
- sqlspec/data_dictionary/_capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_capabilities.py +142 -0
- sqlspec/data_dictionary/_dependencies.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_dependencies.py +602 -0
- sqlspec/data_dictionary/_index_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_index_ddl.py +562 -0
- sqlspec/data_dictionary/_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_loader.py +344 -0
- sqlspec/data_dictionary/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_registry.py +152 -0
- sqlspec/data_dictionary/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_types.py +1852 -0
- sqlspec/data_dictionary/dialects/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/bigquery/__init__.py +15 -0
- sqlspec/data_dictionary/dialects/bigquery/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/bigquery/config.py +128 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/columns.sql +63 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/constraints.sql +37 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/datasets.sql +14 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/ddl.sql +51 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/dependencies.sql +22 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/indexes.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/routines.sql +50 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/system.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/tables.sql +111 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/views.sql +31 -0
- sqlspec/data_dictionary/dialects/cockroachdb/__init__.py +17 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.py +95 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/columns.sql +163 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/comments.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/crdb_internal.sql +11 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/ddl.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/dependencies.sql +20 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/foreign_keys.sql +62 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/indexes.sql +32 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/objects.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/tables.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/views.sql +11 -0
- sqlspec/data_dictionary/dialects/db2/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/db2/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/db2/config.py +172 -0
- sqlspec/data_dictionary/dialects/db2/sql/columns.sql +98 -0
- sqlspec/data_dictionary/dialects/db2/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/db2/sql/foreign_keys.sql +43 -0
- sqlspec/data_dictionary/dialects/db2/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/db2/sql/objects.sql +53 -0
- sqlspec/data_dictionary/dialects/db2/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/db2/sql/tables.sql +77 -0
- sqlspec/data_dictionary/dialects/db2/sql/version.sql +8 -0
- sqlspec/data_dictionary/dialects/db2/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/duckdb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/duckdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/duckdb/config.py +66 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/columns.sql +150 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/constraints.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/databases.sql +11 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/ddl.sql +221 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/dependencies.sql +50 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/extensions.sql +14 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/foreign_keys.sql +46 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/functions.sql +18 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/indexes.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/objects.sql +30 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/sequences.sql +19 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/system.sql +21 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/tables.sql +59 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/types.sql +12 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mariadb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/ddl.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/objects.sql +50 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/privileges.sql +24 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/system.sql +12 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mssql/__init__.py +51 -0
- sqlspec/data_dictionary/dialects/mssql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mssql/config.py +558 -0
- sqlspec/data_dictionary/dialects/mssql/sql/columns.sql +120 -0
- sqlspec/data_dictionary/dialects/mssql/sql/constraints.sql +106 -0
- sqlspec/data_dictionary/dialects/mssql/sql/ddl.sql +89 -0
- sqlspec/data_dictionary/dialects/mssql/sql/dependencies.sql +17 -0
- sqlspec/data_dictionary/dialects/mssql/sql/extended_properties.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/dialects/mssql/sql/indexes.sql +86 -0
- sqlspec/data_dictionary/dialects/mssql/sql/modules.sql +19 -0
- sqlspec/data_dictionary/dialects/mssql/sql/objects.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/permissions.sql +31 -0
- sqlspec/data_dictionary/dialects/mssql/sql/routines.sql +39 -0
- sqlspec/data_dictionary/dialects/mssql/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/mssql/sql/sequences.sql +18 -0
- sqlspec/data_dictionary/dialects/mssql/sql/storage.sql +22 -0
- sqlspec/data_dictionary/dialects/mssql/sql/system.sql +38 -0
- sqlspec/data_dictionary/dialects/mssql/sql/tables.sql +97 -0
- sqlspec/data_dictionary/dialects/mssql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mssql/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mssql/sql/views.sql +18 -0
- sqlspec/data_dictionary/dialects/mysql/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/mysql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mysql/config.py +363 -0
- sqlspec/data_dictionary/dialects/mysql/dictionary.py +650 -0
- sqlspec/data_dictionary/dialects/mysql/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mysql/sql/components.sql +8 -0
- sqlspec/data_dictionary/dialects/mysql/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mysql/sql/ddl.sql +23 -0
- sqlspec/data_dictionary/dialects/mysql/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mysql/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mysql/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mysql/sql/objects.sql +38 -0
- sqlspec/data_dictionary/dialects/mysql/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mysql/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mysql/sql/privileges.sql +26 -0
- sqlspec/data_dictionary/dialects/mysql/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mysql/sql/system.sql +25 -0
- sqlspec/data_dictionary/dialects/mysql/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mysql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/mysql/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/oracle/__init__.py +39 -0
- sqlspec/data_dictionary/dialects/oracle/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/oracle/config.py +266 -0
- sqlspec/data_dictionary/dialects/oracle/sql/arguments.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/columns.sql +103 -0
- sqlspec/data_dictionary/dialects/oracle/sql/comments.sql +22 -0
- sqlspec/data_dictionary/dialects/oracle/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/oracle/sql/ddl.sql +4 -0
- sqlspec/data_dictionary/dialects/oracle/sql/dependencies.sql +16 -0
- sqlspec/data_dictionary/dialects/oracle/sql/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/grants.sql +34 -0
- sqlspec/data_dictionary/dialects/oracle/sql/indexes.sql +87 -0
- sqlspec/data_dictionary/dialects/oracle/sql/lob_storage.sql +28 -0
- sqlspec/data_dictionary/dialects/oracle/sql/materialized_views.sql +27 -0
- sqlspec/data_dictionary/dialects/oracle/sql/objects.sql +26 -0
- sqlspec/data_dictionary/dialects/oracle/sql/partitions.sql +44 -0
- sqlspec/data_dictionary/dialects/oracle/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/sequences.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/source.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/system.sql +37 -0
- sqlspec/data_dictionary/dialects/oracle/sql/tables.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/triggers.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/version.sql +25 -0
- sqlspec/data_dictionary/dialects/oracle/sql/views.sql +49 -0
- sqlspec/data_dictionary/dialects/postgres/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/postgres/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/postgres/config.py +119 -0
- sqlspec/data_dictionary/dialects/postgres/sql/columns.sql +130 -0
- sqlspec/data_dictionary/dialects/postgres/sql/comments.sql +27 -0
- sqlspec/data_dictionary/dialects/postgres/sql/constraints.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/ddl.sql +55 -0
- sqlspec/data_dictionary/dialects/postgres/sql/dependencies.sql +42 -0
- sqlspec/data_dictionary/dialects/postgres/sql/extensions.sql +11 -0
- sqlspec/data_dictionary/dialects/postgres/sql/foreign_keys.sql +72 -0
- sqlspec/data_dictionary/dialects/postgres/sql/indexes.sql +84 -0
- sqlspec/data_dictionary/dialects/postgres/sql/materialized_views.sql +17 -0
- sqlspec/data_dictionary/dialects/postgres/sql/objects.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/partitions.sql +19 -0
- sqlspec/data_dictionary/dialects/postgres/sql/privileges.sql +29 -0
- sqlspec/data_dictionary/dialects/postgres/sql/routines.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/postgres/sql/sequences.sql +32 -0
- sqlspec/data_dictionary/dialects/postgres/sql/system.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/tables.sql +67 -0
- sqlspec/data_dictionary/dialects/postgres/sql/triggers.sql +20 -0
- sqlspec/data_dictionary/dialects/postgres/sql/types.sql +21 -0
- sqlspec/data_dictionary/dialects/postgres/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/postgres/sql/views.sql +17 -0
- sqlspec/data_dictionary/dialects/snowflake/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/snowflake/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/snowflake/config.py +321 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/columns.sql +48 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/constraints.sql +64 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/ddl.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/foreign_keys.sql +7 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/objects.sql +34 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/routines.sql +79 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/schemas.sql +19 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/sequences.sql +45 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/tables.sql +29 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/views.sql +37 -0
- sqlspec/data_dictionary/dialects/spanner/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/spanner/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/spanner/config.py +67 -0
- sqlspec/data_dictionary/dialects/spanner/sql/columns.sql +58 -0
- sqlspec/data_dictionary/dialects/spanner/sql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/columns.sql +46 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/database.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/indexes.sql +66 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/placements.sql +8 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/property_graphs.sql +11 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/routines.sql +33 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/tables.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/views.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/indexes.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/columns.sql +34 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/indexes.sql +52 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/spanner/sql/tables.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.py +191 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/columns.sql +97 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/constraints.sql +43 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/objects.sql +18 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/schemas.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/tables.sql +86 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlite/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/sqlite/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlite/config.py +412 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/columns.sql +59 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/compile_options.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/ddl.sql +37 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/functions.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/indexes.sql +76 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/modules.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/schemas.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/system.sql +7 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/triggers.sql +10 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/views.sql +10 -0
- sqlspec/data_dictionary/dialects/sybase/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sybase/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sybase/config.py +187 -0
- sqlspec/data_dictionary/dialects/sybase/sql/columns.sql +137 -0
- sqlspec/data_dictionary/dialects/sybase/sql/constraints.sql +85 -0
- sqlspec/data_dictionary/dialects/sybase/sql/foreign_keys.sql +81 -0
- sqlspec/data_dictionary/dialects/sybase/sql/indexes.sql +51 -0
- sqlspec/data_dictionary/dialects/sybase/sql/objects.sql +21 -0
- sqlspec/data_dictionary/dialects/sybase/sql/schemas.sql +16 -0
- sqlspec/data_dictionary/dialects/sybase/sql/tables.sql +46 -0
- sqlspec/data_dictionary/dialects/sybase/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sybase/sql/views.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/__init__.py +33 -0
- sqlspec/data_dictionary/dialects/teradata/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/teradata/config.py +228 -0
- sqlspec/data_dictionary/dialects/teradata/sql/columns.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/constraints.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/sql/foreign_keys.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/indexes.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/objects.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/schemas.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/version.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/views.sql +4 -0
- sqlspec/dialects/__init__.py +44 -0
- sqlspec/dialects/db2/__init__.py +111 -0
- sqlspec/dialects/db2/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_generators.py +376 -0
- sqlspec/dialects/db2/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_parsers.py +657 -0
- sqlspec/dialects/db2/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_transforms.py +175 -0
- sqlspec/dialects/postgres/__init__.py +10 -0
- sqlspec/dialects/postgres/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_generators.py +81 -0
- sqlspec/dialects/postgres/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_operators.py +95 -0
- sqlspec/dialects/postgres/_paradedb.py +44 -0
- sqlspec/dialects/postgres/_pg_textsearch.py +38 -0
- sqlspec/dialects/postgres/_pgvector.py +36 -0
- sqlspec/dialects/spanner/__init__.py +69 -0
- sqlspec/dialects/spanner/_expressions.py +247 -0
- sqlspec/dialects/spanner/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_generators.py +961 -0
- sqlspec/dialects/spanner/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_parsers.py +871 -0
- sqlspec/dialects/spanner/_spangres.py +43 -0
- sqlspec/dialects/spanner/_spanner.py +57 -0
- sqlspec/dialects/sybase/__init__.py +115 -0
- sqlspec/dialects/sybase/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_generators.py +379 -0
- sqlspec/dialects/sybase/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_parsers.py +225 -0
- sqlspec/dialects/sybase/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_transforms.py +68 -0
- sqlspec/dialects/teradata/__init__.py +42 -0
- sqlspec/dialects/teradata/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/teradata/_generators.py +203 -0
- sqlspec/driver/__init__.py +151 -0
- sqlspec/driver/_async.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_async.py +3244 -0
- sqlspec/driver/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_common.py +4765 -0
- sqlspec/driver/_deferred.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_deferred.py +232 -0
- sqlspec/driver/_exception_handler.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_exception_handler.py +224 -0
- sqlspec/driver/_routing.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_routing.py +2891 -0
- sqlspec/driver/_session.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_session.py +180 -0
- sqlspec/driver/_sql_helpers.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sql_helpers.py +140 -0
- sqlspec/driver/_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_stream.py +392 -0
- sqlspec/driver/_sync.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sync.py +3107 -0
- sqlspec/driver/_tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_tenant.py +326 -0
- sqlspec/exceptions.cp315-win_amd64.pyd +0 -0
- sqlspec/exceptions.py +568 -0
- sqlspec/extensions/__init__.py +3 -0
- sqlspec/extensions/adk/__init__.py +136 -0
- sqlspec/extensions/adk/_config_utils.py +306 -0
- sqlspec/extensions/adk/_table_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_table_utils.py +126 -0
- sqlspec/extensions/adk/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_types.py +59 -0
- sqlspec/extensions/adk/artifact/__init__.py +18 -0
- sqlspec/extensions/adk/artifact/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/artifact/_types.py +41 -0
- sqlspec/extensions/adk/artifact/service.py +657 -0
- sqlspec/extensions/adk/artifact/store.py +444 -0
- sqlspec/extensions/adk/converters.py +230 -0
- sqlspec/extensions/adk/maintenance.py +262 -0
- sqlspec/extensions/adk/memory/__init__.py +36 -0
- sqlspec/extensions/adk/memory/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/memory/_types.py +48 -0
- sqlspec/extensions/adk/memory/converters.py +271 -0
- sqlspec/extensions/adk/memory/service.py +474 -0
- sqlspec/extensions/adk/memory/store.py +586 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +181 -0
- sqlspec/extensions/adk/migrations/0002_create_mssql_python_memory.py +51 -0
- sqlspec/extensions/adk/migrations/__init__.py +3 -0
- sqlspec/extensions/adk/migrations/reconcile.py +282 -0
- sqlspec/extensions/adk/service.py +463 -0
- sqlspec/extensions/adk/store.py +1239 -0
- sqlspec/extensions/events/__init__.py +132 -0
- sqlspec/extensions/events/_buffer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_buffer.py +38 -0
- sqlspec/extensions/events/_channel.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_channel.py +1144 -0
- sqlspec/extensions/events/_hints.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_hints.py +38 -0
- sqlspec/extensions/events/_models.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_models.py +22 -0
- sqlspec/extensions/events/_names.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_names.py +27 -0
- sqlspec/extensions/events/_payload.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_payload.py +139 -0
- sqlspec/extensions/events/_protocols.py +154 -0
- sqlspec/extensions/events/_queue.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_queue.py +1147 -0
- sqlspec/extensions/events/_store.py +318 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +106 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/events/migrations/reconcile.py +145 -0
- sqlspec/extensions/events/primitives.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/primitives.py +91 -0
- sqlspec/extensions/fastapi/__init__.py +26 -0
- sqlspec/extensions/fastapi/extension.py +360 -0
- sqlspec/extensions/fastapi/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/fastapi/providers.py +1091 -0
- sqlspec/extensions/flask/__init__.py +20 -0
- sqlspec/extensions/flask/_portal.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_portal.py +212 -0
- sqlspec/extensions/flask/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_state.py +135 -0
- sqlspec/extensions/flask/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_utils.py +171 -0
- sqlspec/extensions/flask/extension.py +1234 -0
- sqlspec/extensions/litestar/__init__.py +52 -0
- sqlspec/extensions/litestar/_tenant_resolution.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_tenant_resolution.py +314 -0
- sqlspec/extensions/litestar/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_utils.py +222 -0
- sqlspec/extensions/litestar/channels.py +249 -0
- sqlspec/extensions/litestar/cli.py +100 -0
- sqlspec/extensions/litestar/config.py +5 -0
- sqlspec/extensions/litestar/handlers.py +796 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +138 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/migrations/reconcile.py +132 -0
- sqlspec/extensions/litestar/plugin.py +2172 -0
- sqlspec/extensions/litestar/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/providers.py +1239 -0
- sqlspec/extensions/litestar/store.py +613 -0
- sqlspec/extensions/litestar/tenant.py +292 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +5 -0
- sqlspec/extensions/prometheus/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/prometheus/_observer.py +152 -0
- sqlspec/extensions/sanic/__init__.py +28 -0
- sqlspec/extensions/sanic/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_state.py +102 -0
- sqlspec/extensions/sanic/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_utils.py +234 -0
- sqlspec/extensions/sanic/extension.py +1467 -0
- sqlspec/extensions/starlette/__init__.py +31 -0
- sqlspec/extensions/starlette/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_state.py +103 -0
- sqlspec/extensions/starlette/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_utils.py +267 -0
- sqlspec/extensions/starlette/extension.py +691 -0
- sqlspec/extensions/starlette/middleware.py +845 -0
- sqlspec/loader.cp315-win_amd64.pyd +0 -0
- sqlspec/loader.py +1733 -0
- sqlspec/migrations/__init__.py +104 -0
- sqlspec/migrations/_backup.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/_backup.py +36 -0
- sqlspec/migrations/base.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/base.py +1688 -0
- sqlspec/migrations/commands.py +4002 -0
- sqlspec/migrations/context.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/context.py +158 -0
- sqlspec/migrations/fix.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/fix.py +193 -0
- sqlspec/migrations/loaders.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/loaders.py +835 -0
- sqlspec/migrations/runner.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/runner.py +2144 -0
- sqlspec/migrations/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/schema.py +1266 -0
- sqlspec/migrations/squash.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/squash.py +2452 -0
- sqlspec/migrations/templates.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/templates.py +310 -0
- sqlspec/migrations/tracker.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/tracker.py +1529 -0
- sqlspec/migrations/utils.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/utils.py +534 -0
- sqlspec/migrations/validation.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/validation.py +355 -0
- sqlspec/migrations/version.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/version.py +455 -0
- sqlspec/observability/__init__.py +122 -0
- sqlspec/observability/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_common.py +307 -0
- sqlspec/observability/_config.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_config.py +362 -0
- sqlspec/observability/_diagnostics.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_diagnostics.py +75 -0
- sqlspec/observability/_dispatcher.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_dispatcher.py +320 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_aws.py +90 -0
- sqlspec/observability/_formatters/_azure.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_azure.py +84 -0
- sqlspec/observability/_formatters/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_base.py +40 -0
- sqlspec/observability/_formatters/_gcp.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_gcp.py +119 -0
- sqlspec/observability/_formatting.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatting.py +76 -0
- sqlspec/observability/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_observer.py +445 -0
- sqlspec/observability/_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_runtime.py +740 -0
- sqlspec/observability/_sampling.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_sampling.py +169 -0
- sqlspec/observability/_spans.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_spans.py +212 -0
- sqlspec/protocols.py +1235 -0
- sqlspec/py.typed +0 -0
- sqlspec/service/__init__.py +5 -0
- sqlspec/service/_base.py +1051 -0
- sqlspec/service/_core.cp315-win_amd64.pyd +0 -0
- sqlspec/service/_core.py +625 -0
- sqlspec/storage/__init__.py +111 -0
- sqlspec/storage/_arrow_payload.py +802 -0
- sqlspec/storage/_arrow_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_arrow_stream.py +134 -0
- sqlspec/storage/_ingest.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_ingest.py +810 -0
- sqlspec/storage/_paths.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_paths.py +313 -0
- sqlspec/storage/_staging_sql.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_staging_sql.py +695 -0
- sqlspec/storage/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_utils.py +174 -0
- sqlspec/storage/backends/__init__.py +43 -0
- sqlspec/storage/backends/base.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/base.py +399 -0
- sqlspec/storage/backends/fsspec.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/fsspec.py +1390 -0
- sqlspec/storage/backends/local.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/local.py +968 -0
- sqlspec/storage/backends/obstore.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/obstore.py +1974 -0
- sqlspec/storage/errors.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/errors.py +127 -0
- sqlspec/storage/pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/pipeline.py +1270 -0
- sqlspec/storage/registry.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/registry.py +318 -0
- sqlspec/typing.py +261 -0
- sqlspec/utils/__init__.py +9 -0
- sqlspec/utils/adapters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/adapters.py +186 -0
- sqlspec/utils/arrow_helpers.py +2157 -0
- sqlspec/utils/config_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/config_tools.py +712 -0
- sqlspec/utils/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/correlation.py +137 -0
- sqlspec/utils/deprecation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/deprecation.py +222 -0
- sqlspec/utils/dispatch.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/dispatch.py +104 -0
- sqlspec/utils/env.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/env.py +437 -0
- sqlspec/utils/fixtures.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/fixtures.py +2470 -0
- sqlspec/utils/logging.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/logging.py +267 -0
- sqlspec/utils/module_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/module_loader.py +399 -0
- sqlspec/utils/portal.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/portal.py +411 -0
- sqlspec/utils/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/routing.py +645 -0
- sqlspec/utils/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/schema.py +1050 -0
- sqlspec/utils/serializers/__init__.py +69 -0
- sqlspec/utils/serializers/_json.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_json.py +525 -0
- sqlspec/utils/serializers/_numpy.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_numpy.py +65 -0
- sqlspec/utils/serializers/_schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_schema.py +340 -0
- sqlspec/utils/sync_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/sync_tools.py +502 -0
- sqlspec/utils/tenant/__init__.py +71 -0
- sqlspec/utils/tenant/_context.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_context.py +550 -0
- sqlspec/utils/tenant/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_cursor.py +43 -0
- sqlspec/utils/tenant/_mssql.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_mssql.py +189 -0
- sqlspec/utils/tenant/_postgres.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_postgres.py +142 -0
- sqlspec/utils/text.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/text.py +317 -0
- sqlspec/utils/type_converters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_converters.py +220 -0
- sqlspec/utils/type_guards.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_guards.py +1505 -0
- sqlspec/utils/uuids.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/uuids.py +263 -0
- sqlspec-0.72.0.dist-info/METADATA +228 -0
- sqlspec-0.72.0.dist-info/RECORD +1144 -0
- sqlspec-0.72.0.dist-info/WHEEL +4 -0
- sqlspec-0.72.0.dist-info/entry_points.txt +13 -0
- sqlspec-0.72.0.dist-info/licenses/LICENSE +21 -0
sqlspec/base.py
ADDED
|
@@ -0,0 +1,1275 @@
|
|
|
1
|
+
"""Core SQLSpec registry and session management entry point."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import atexit
|
|
5
|
+
import weakref
|
|
6
|
+
from collections.abc import Awaitable, Coroutine, Sequence
|
|
7
|
+
from contextlib import AbstractAsyncContextManager, AbstractContextManager
|
|
8
|
+
from typing import TYPE_CHECKING, Any, ClassVar, Generic, Self, TypeGuard, cast, overload
|
|
9
|
+
|
|
10
|
+
from mypy_extensions import mypyc_attr
|
|
11
|
+
from typing_extensions import TypeVar
|
|
12
|
+
|
|
13
|
+
from sqlspec.config import (
|
|
14
|
+
AsyncConfigT,
|
|
15
|
+
AsyncDatabaseConfig,
|
|
16
|
+
DatabaseConfigProtocol,
|
|
17
|
+
DriverT,
|
|
18
|
+
NoPoolAsyncConfig,
|
|
19
|
+
NoPoolSyncConfig,
|
|
20
|
+
SyncConfigT,
|
|
21
|
+
SyncDatabaseConfig,
|
|
22
|
+
)
|
|
23
|
+
from sqlspec.core.cache import (
|
|
24
|
+
CacheConfig,
|
|
25
|
+
get_cache_config,
|
|
26
|
+
get_cache_statistics,
|
|
27
|
+
log_cache_stats,
|
|
28
|
+
reset_stats_only,
|
|
29
|
+
update_cache_config,
|
|
30
|
+
)
|
|
31
|
+
from sqlspec.driver._common import _CLOSED_CONNECTION
|
|
32
|
+
from sqlspec.exceptions import ImproperConfigurationError
|
|
33
|
+
from sqlspec.extensions.events._channel import AsyncEventChannel, SyncEventChannel
|
|
34
|
+
from sqlspec.loader import SQLFileLoader
|
|
35
|
+
from sqlspec.observability._diagnostics import TelemetryDiagnostics
|
|
36
|
+
from sqlspec.observability._runtime import ObservabilityRuntime
|
|
37
|
+
from sqlspec.typing import ConnectionT
|
|
38
|
+
from sqlspec.utils.logging import get_logger
|
|
39
|
+
from sqlspec.utils.type_guards import has_name
|
|
40
|
+
|
|
41
|
+
if TYPE_CHECKING:
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
from types import TracebackType
|
|
44
|
+
from uuid import UUID
|
|
45
|
+
|
|
46
|
+
from sqlspec.core.parameters._declared import ParameterDeclaration
|
|
47
|
+
from sqlspec.core.statement import SQL, StatementConfig
|
|
48
|
+
from sqlspec.driver._routing import AsyncDriverT, AsyncRoutingSession, SyncDriverT, SyncRoutingSession
|
|
49
|
+
from sqlspec.observability._config import ObservabilityConfig
|
|
50
|
+
from sqlspec.typing import PoolT
|
|
51
|
+
from sqlspec.utils.tenant._context import TenantContextPayload
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
__all__ = ("SQLSpec", "coerce_sqlspec")
|
|
55
|
+
|
|
56
|
+
logger = get_logger()
|
|
57
|
+
ContextValueT = TypeVar("ContextValueT")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@mypyc_attr(allow_interpreted_subclasses=True, native_class=False)
|
|
61
|
+
class SQLSpec:
|
|
62
|
+
"""Configuration manager and registry for database connections and pools."""
|
|
63
|
+
|
|
64
|
+
__slots__ = ("__weakref__", "_configs", "_loader", "_loader_runtime", "_observability_config")
|
|
65
|
+
|
|
66
|
+
_live_instances: "ClassVar[weakref.WeakSet[SQLSpec]]" = weakref.WeakSet()
|
|
67
|
+
_atexit_registered: ClassVar[bool] = False
|
|
68
|
+
|
|
69
|
+
def __init__(
|
|
70
|
+
self, *, loader: "SQLFileLoader | None" = None, observability_config: "ObservabilityConfig | None" = None
|
|
71
|
+
) -> None:
|
|
72
|
+
self._configs: dict[int, DatabaseConfigProtocol[Any, Any, Any]] = {}
|
|
73
|
+
SQLSpec._live_instances.add(self)
|
|
74
|
+
if not SQLSpec._atexit_registered:
|
|
75
|
+
atexit.register(SQLSpec._cleanup_all_sync_pools)
|
|
76
|
+
SQLSpec._atexit_registered = True
|
|
77
|
+
self._observability_config = observability_config
|
|
78
|
+
self._loader_runtime = ObservabilityRuntime(observability_config, config_name="SQLFileLoader")
|
|
79
|
+
self._loader = loader
|
|
80
|
+
if self._loader is not None:
|
|
81
|
+
self._loader.set_observability_runtime(self._loader_runtime)
|
|
82
|
+
|
|
83
|
+
async def __aenter__(self) -> Self:
|
|
84
|
+
"""Async context manager entry."""
|
|
85
|
+
return self
|
|
86
|
+
|
|
87
|
+
async def __aexit__(
|
|
88
|
+
self, _exc_type: "type[BaseException] | None", _exc_val: "BaseException | None", _exc_tb: "TracebackType | None"
|
|
89
|
+
) -> None:
|
|
90
|
+
"""Async context manager exit with automatic cleanup."""
|
|
91
|
+
await self.close_all_pools()
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def configs(self) -> "dict[int, DatabaseConfigProtocol[Any, Any, Any]]":
|
|
95
|
+
"""Access the registry of database configurations.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
Dictionary mapping config instance IDs to config instances.
|
|
99
|
+
"""
|
|
100
|
+
return self._configs
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def loader(self) -> SQLFileLoader:
|
|
104
|
+
"""Access the SQL file loader.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
The configured or lazily initialized SQL file loader.
|
|
108
|
+
"""
|
|
109
|
+
return self._ensure_loader()
|
|
110
|
+
|
|
111
|
+
@overload
|
|
112
|
+
def add_config(self, config: "SyncConfigT") -> "SyncConfigT": ...
|
|
113
|
+
@overload
|
|
114
|
+
def add_config(self, config: "AsyncConfigT") -> "AsyncConfigT": ...
|
|
115
|
+
def add_config(self, config: "SyncConfigT | AsyncConfigT") -> "SyncConfigT | AsyncConfigT":
|
|
116
|
+
"""Add a configuration instance to the registry.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
config: The configuration instance to add.
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
The same configuration instance (it IS the handle).
|
|
123
|
+
"""
|
|
124
|
+
config_id = id(config)
|
|
125
|
+
if config_id in self._configs:
|
|
126
|
+
logger.debug("Configuration for %s already exists. Overwriting.", config.__class__.__name__)
|
|
127
|
+
config.attach_observability(self._observability_config)
|
|
128
|
+
self._configs[config_id] = config
|
|
129
|
+
return config
|
|
130
|
+
|
|
131
|
+
@overload
|
|
132
|
+
def get_connection(
|
|
133
|
+
self, config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT]"
|
|
134
|
+
) -> "ConnectionT": ...
|
|
135
|
+
@overload
|
|
136
|
+
def get_connection(
|
|
137
|
+
self, config: "NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]"
|
|
138
|
+
) -> "Awaitable[ConnectionT]": ...
|
|
139
|
+
def get_connection(
|
|
140
|
+
self,
|
|
141
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
142
|
+
) -> "ConnectionT | Awaitable[ConnectionT]":
|
|
143
|
+
"""Get a database connection for the specified configuration.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
config: The configuration instance.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
A database connection or an awaitable yielding a connection.
|
|
150
|
+
"""
|
|
151
|
+
self._ensure_registered(config)
|
|
152
|
+
|
|
153
|
+
return config.create_connection()
|
|
154
|
+
|
|
155
|
+
@overload
|
|
156
|
+
def get_session(
|
|
157
|
+
self, config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT]"
|
|
158
|
+
) -> "DriverT": ...
|
|
159
|
+
@overload
|
|
160
|
+
def get_session(
|
|
161
|
+
self, config: "NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]"
|
|
162
|
+
) -> "Awaitable[DriverT]": ...
|
|
163
|
+
def get_session(
|
|
164
|
+
self,
|
|
165
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
166
|
+
) -> "DriverT | Awaitable[DriverT]":
|
|
167
|
+
"""Get a database session (driver adapter) for the specified configuration.
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
config: The configuration instance.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
A driver adapter instance or an awaitable yielding one.
|
|
174
|
+
"""
|
|
175
|
+
self._ensure_registered(config)
|
|
176
|
+
|
|
177
|
+
connection_obj = self.get_connection(config)
|
|
178
|
+
|
|
179
|
+
if isinstance(connection_obj, Awaitable):
|
|
180
|
+
async_config = cast(
|
|
181
|
+
"NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]", config
|
|
182
|
+
)
|
|
183
|
+
return self._driver_from_async_connection(async_config, connection_obj) # pyright: ignore
|
|
184
|
+
|
|
185
|
+
driver = config.driver_type( # pyright: ignore
|
|
186
|
+
connection=connection_obj, statement_config=config.statement_config, driver_features=config.driver_features
|
|
187
|
+
)
|
|
188
|
+
return config._prepare_driver(driver) # pyright: ignore
|
|
189
|
+
|
|
190
|
+
@overload
|
|
191
|
+
def provide_connection(
|
|
192
|
+
self,
|
|
193
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
194
|
+
*args: Any,
|
|
195
|
+
**kwargs: Any,
|
|
196
|
+
) -> "AbstractContextManager[ConnectionT]": ...
|
|
197
|
+
@overload
|
|
198
|
+
def provide_connection(
|
|
199
|
+
self,
|
|
200
|
+
config: "NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
201
|
+
*args: Any,
|
|
202
|
+
**kwargs: Any,
|
|
203
|
+
) -> "AbstractAsyncContextManager[ConnectionT]": ...
|
|
204
|
+
def provide_connection(
|
|
205
|
+
self,
|
|
206
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
207
|
+
*args: Any,
|
|
208
|
+
**kwargs: Any,
|
|
209
|
+
) -> "AbstractContextManager[ConnectionT] | AbstractAsyncContextManager[ConnectionT]":
|
|
210
|
+
"""Create and provide a database connection from the specified configuration.
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
config: The configuration instance.
|
|
214
|
+
*args: Positional arguments to pass to the config's provide_connection.
|
|
215
|
+
**kwargs: Keyword arguments to pass to the config's provide_connection.
|
|
216
|
+
|
|
217
|
+
Returns:
|
|
218
|
+
A sync or async context manager yielding a connection.
|
|
219
|
+
"""
|
|
220
|
+
self._ensure_registered(config)
|
|
221
|
+
|
|
222
|
+
connection_context = config.provide_connection(*args, **kwargs)
|
|
223
|
+
runtime = config.get_observability_runtime()
|
|
224
|
+
if not runtime.has_session_lifecycle:
|
|
225
|
+
return connection_context
|
|
226
|
+
|
|
227
|
+
config_is_async = getattr(config, "is_async", None)
|
|
228
|
+
is_async = config_is_async if type(config_is_async) is bool else _is_async_context_manager(connection_context)
|
|
229
|
+
if is_async:
|
|
230
|
+
return _RuntimeAsyncContext(cast("AbstractAsyncContextManager[Any]", connection_context), runtime)
|
|
231
|
+
|
|
232
|
+
return _RuntimeSyncContext(cast("AbstractContextManager[Any]", connection_context), runtime)
|
|
233
|
+
|
|
234
|
+
@overload
|
|
235
|
+
def provide_session(
|
|
236
|
+
self,
|
|
237
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
238
|
+
*args: Any,
|
|
239
|
+
statement_config: "StatementConfig | None" = None,
|
|
240
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
241
|
+
bypass_tenant: bool = False,
|
|
242
|
+
**kwargs: Any,
|
|
243
|
+
) -> "AbstractContextManager[DriverT]": ...
|
|
244
|
+
@overload
|
|
245
|
+
def provide_session(
|
|
246
|
+
self,
|
|
247
|
+
config: "NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
248
|
+
*args: Any,
|
|
249
|
+
statement_config: "StatementConfig | None" = None,
|
|
250
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
251
|
+
bypass_tenant: bool = False,
|
|
252
|
+
**kwargs: Any,
|
|
253
|
+
) -> "AbstractAsyncContextManager[DriverT]": ...
|
|
254
|
+
def provide_session(
|
|
255
|
+
self,
|
|
256
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
257
|
+
*args: Any,
|
|
258
|
+
statement_config: "StatementConfig | None" = None,
|
|
259
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
260
|
+
bypass_tenant: bool = False,
|
|
261
|
+
**kwargs: Any,
|
|
262
|
+
) -> "AbstractContextManager[DriverT] | AbstractAsyncContextManager[DriverT]":
|
|
263
|
+
"""Create and provide a database session from the specified configuration.
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
config: The configuration instance.
|
|
267
|
+
*args: Positional arguments to pass to the config's provide_session.
|
|
268
|
+
statement_config: Statement configuration override.
|
|
269
|
+
tenant: Tenant identity or payload; None inherits the current scope.
|
|
270
|
+
bypass_tenant: Explicitly bypass tenant setup for this session.
|
|
271
|
+
**kwargs: Keyword arguments to pass to the config's provide_session.
|
|
272
|
+
|
|
273
|
+
Returns:
|
|
274
|
+
A sync or async context manager yielding a driver adapter instance.
|
|
275
|
+
"""
|
|
276
|
+
self._ensure_registered(config)
|
|
277
|
+
|
|
278
|
+
if statement_config is not None or tenant is not None or bypass_tenant:
|
|
279
|
+
call_kwargs = dict(kwargs) if kwargs else {}
|
|
280
|
+
if statement_config is not None:
|
|
281
|
+
call_kwargs["statement_config"] = statement_config
|
|
282
|
+
if tenant is not None:
|
|
283
|
+
call_kwargs["tenant"] = tenant
|
|
284
|
+
if bypass_tenant:
|
|
285
|
+
call_kwargs["bypass_tenant"] = True
|
|
286
|
+
session_context = config.provide_session(*args, **call_kwargs)
|
|
287
|
+
elif kwargs:
|
|
288
|
+
session_context = config.provide_session(*args, **kwargs)
|
|
289
|
+
else:
|
|
290
|
+
session_context = config.provide_session(*args)
|
|
291
|
+
runtime = config.get_observability_runtime()
|
|
292
|
+
if not runtime.has_session_lifecycle and isinstance(
|
|
293
|
+
config, (SyncDatabaseConfig, AsyncDatabaseConfig, NoPoolSyncConfig, NoPoolAsyncConfig)
|
|
294
|
+
):
|
|
295
|
+
return session_context
|
|
296
|
+
|
|
297
|
+
config_is_async = getattr(config, "is_async", None)
|
|
298
|
+
is_async = config_is_async if type(config_is_async) is bool else _is_async_context_manager(session_context)
|
|
299
|
+
if is_async:
|
|
300
|
+
return _RuntimeAsyncContext(cast("AbstractAsyncContextManager[Any]", session_context), runtime, config)
|
|
301
|
+
|
|
302
|
+
return _RuntimeSyncContext(cast("AbstractContextManager[Any]", session_context), runtime, config)
|
|
303
|
+
|
|
304
|
+
@overload
|
|
305
|
+
def provide_replica_connection(
|
|
306
|
+
self,
|
|
307
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
308
|
+
*args: Any,
|
|
309
|
+
replica_group: str | None = None,
|
|
310
|
+
**kwargs: Any,
|
|
311
|
+
) -> "AbstractContextManager[ConnectionT]": ...
|
|
312
|
+
@overload
|
|
313
|
+
def provide_replica_connection(
|
|
314
|
+
self,
|
|
315
|
+
config: "NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
316
|
+
*args: Any,
|
|
317
|
+
replica_group: str | None = None,
|
|
318
|
+
**kwargs: Any,
|
|
319
|
+
) -> "AbstractAsyncContextManager[ConnectionT]": ...
|
|
320
|
+
def provide_replica_connection(
|
|
321
|
+
self,
|
|
322
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
323
|
+
*args: Any,
|
|
324
|
+
replica_group: str | None = None,
|
|
325
|
+
**kwargs: Any,
|
|
326
|
+
) -> "AbstractContextManager[ConnectionT] | AbstractAsyncContextManager[ConnectionT]":
|
|
327
|
+
"""Provide a replica connection with lifecycle events owned by the selected configuration.
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
config: Configuration instance owning the replica topology.
|
|
331
|
+
*args: Positional arguments forwarded to the read provider.
|
|
332
|
+
replica_group: Named replica group, or the default group.
|
|
333
|
+
**kwargs: Additional read provider arguments.
|
|
334
|
+
|
|
335
|
+
Returns:
|
|
336
|
+
A context manager yielding the selected connection.
|
|
337
|
+
"""
|
|
338
|
+
self._ensure_registered(config)
|
|
339
|
+
context = config.provide_replica_connection(*args, replica_group=replica_group, **kwargs)
|
|
340
|
+
if _is_async_context_manager(context):
|
|
341
|
+
return _RuntimeReadAsyncContext[ConnectionT](context, session=False)
|
|
342
|
+
return _RuntimeReadSyncContext[ConnectionT](cast("AbstractContextManager[ConnectionT]", context), session=False)
|
|
343
|
+
|
|
344
|
+
@overload
|
|
345
|
+
def provide_replica_session(
|
|
346
|
+
self,
|
|
347
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
348
|
+
*args: Any,
|
|
349
|
+
replica_group: str | None = None,
|
|
350
|
+
statement_config: "StatementConfig | None" = None,
|
|
351
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
352
|
+
bypass_tenant: bool = False,
|
|
353
|
+
**kwargs: Any,
|
|
354
|
+
) -> "AbstractContextManager[DriverT]": ...
|
|
355
|
+
@overload
|
|
356
|
+
def provide_replica_session(
|
|
357
|
+
self,
|
|
358
|
+
config: "NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
359
|
+
*args: Any,
|
|
360
|
+
replica_group: str | None = None,
|
|
361
|
+
statement_config: "StatementConfig | None" = None,
|
|
362
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
363
|
+
bypass_tenant: bool = False,
|
|
364
|
+
**kwargs: Any,
|
|
365
|
+
) -> "AbstractAsyncContextManager[DriverT]": ...
|
|
366
|
+
def provide_replica_session(
|
|
367
|
+
self,
|
|
368
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
369
|
+
*args: Any,
|
|
370
|
+
replica_group: str | None = None,
|
|
371
|
+
statement_config: "StatementConfig | None" = None,
|
|
372
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
373
|
+
bypass_tenant: bool = False,
|
|
374
|
+
**kwargs: Any,
|
|
375
|
+
) -> "AbstractContextManager[DriverT] | AbstractAsyncContextManager[DriverT]":
|
|
376
|
+
"""Provide a replica session with lifecycle events owned by the selected configuration.
|
|
377
|
+
|
|
378
|
+
Args:
|
|
379
|
+
config: Configuration instance owning the replica topology.
|
|
380
|
+
*args: Positional arguments forwarded to the read provider.
|
|
381
|
+
replica_group: Named replica group, or the default group.
|
|
382
|
+
statement_config: Statement configuration override.
|
|
383
|
+
tenant: Tenant identity or payload for the selected session.
|
|
384
|
+
bypass_tenant: Explicitly bypass tenant setup.
|
|
385
|
+
**kwargs: Additional read provider arguments.
|
|
386
|
+
|
|
387
|
+
Returns:
|
|
388
|
+
A context manager yielding the selected session.
|
|
389
|
+
"""
|
|
390
|
+
self._ensure_registered(config)
|
|
391
|
+
context = config.provide_replica_session(
|
|
392
|
+
*args,
|
|
393
|
+
replica_group=replica_group,
|
|
394
|
+
statement_config=statement_config,
|
|
395
|
+
tenant=tenant,
|
|
396
|
+
bypass_tenant=bypass_tenant,
|
|
397
|
+
**kwargs,
|
|
398
|
+
)
|
|
399
|
+
if _is_async_context_manager(context):
|
|
400
|
+
return _RuntimeReadAsyncContext[DriverT](context, session=True)
|
|
401
|
+
return _RuntimeReadSyncContext[DriverT](cast("AbstractContextManager[DriverT]", context), session=True)
|
|
402
|
+
|
|
403
|
+
@overload
|
|
404
|
+
def provide_routing_session(
|
|
405
|
+
self,
|
|
406
|
+
config: "SyncDatabaseConfig[ConnectionT, PoolT, SyncDriverT] | NoPoolSyncConfig[ConnectionT, SyncDriverT]",
|
|
407
|
+
*,
|
|
408
|
+
replica_group: str | None = None,
|
|
409
|
+
statement_config: "StatementConfig | None" = None,
|
|
410
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
411
|
+
bypass_tenant: bool = False,
|
|
412
|
+
) -> "SyncRoutingSession[SyncDriverT]": ...
|
|
413
|
+
@overload
|
|
414
|
+
def provide_routing_session(
|
|
415
|
+
self,
|
|
416
|
+
config: "AsyncDatabaseConfig[ConnectionT, PoolT, AsyncDriverT] | NoPoolAsyncConfig[ConnectionT, AsyncDriverT]",
|
|
417
|
+
*,
|
|
418
|
+
replica_group: str | None = None,
|
|
419
|
+
statement_config: "StatementConfig | None" = None,
|
|
420
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
421
|
+
bypass_tenant: bool = False,
|
|
422
|
+
) -> "AsyncRoutingSession[AsyncDriverT]": ...
|
|
423
|
+
def provide_routing_session(
|
|
424
|
+
self,
|
|
425
|
+
config: "SyncDatabaseConfig[ConnectionT, PoolT, SyncDriverT] | NoPoolSyncConfig[ConnectionT, SyncDriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, AsyncDriverT] | NoPoolAsyncConfig[ConnectionT, AsyncDriverT]",
|
|
426
|
+
*,
|
|
427
|
+
replica_group: str | None = None,
|
|
428
|
+
statement_config: "StatementConfig | None" = None,
|
|
429
|
+
tenant: "str | UUID | TenantContextPayload | None" = None,
|
|
430
|
+
bypass_tenant: bool = False,
|
|
431
|
+
) -> "SyncRoutingSession[SyncDriverT] | AsyncRoutingSession[AsyncDriverT]":
|
|
432
|
+
"""Create a lazy routing session managed by this registry.
|
|
433
|
+
|
|
434
|
+
Args:
|
|
435
|
+
config: Configuration instance owning the replica topology.
|
|
436
|
+
replica_group: Replica group used for eligible reads.
|
|
437
|
+
statement_config: Statement configuration override.
|
|
438
|
+
tenant: Tenant identity or payload for physical checkouts.
|
|
439
|
+
bypass_tenant: Explicitly bypass tenant setup.
|
|
440
|
+
|
|
441
|
+
Returns:
|
|
442
|
+
A lazy routing facade preserving the configured driver type.
|
|
443
|
+
"""
|
|
444
|
+
self._ensure_registered(config)
|
|
445
|
+
session = config.provide_routing_session(
|
|
446
|
+
replica_group=replica_group, statement_config=statement_config, tenant=tenant, bypass_tenant=bypass_tenant
|
|
447
|
+
)
|
|
448
|
+
session._registry_lifecycle = True
|
|
449
|
+
return session
|
|
450
|
+
|
|
451
|
+
@overload
|
|
452
|
+
def get_pool(
|
|
453
|
+
self, config: "NoPoolSyncConfig[ConnectionT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT]"
|
|
454
|
+
) -> None: ...
|
|
455
|
+
@overload
|
|
456
|
+
def get_pool(self, config: "SyncDatabaseConfig[ConnectionT, PoolT, DriverT]") -> "type[PoolT]": ...
|
|
457
|
+
@overload
|
|
458
|
+
def get_pool(self, config: "AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]") -> "Awaitable[type[PoolT]]": ...
|
|
459
|
+
def get_pool(
|
|
460
|
+
self,
|
|
461
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
462
|
+
) -> "type[PoolT] | Awaitable[type[PoolT]] | None":
|
|
463
|
+
"""Get the connection pool for the specified configuration.
|
|
464
|
+
|
|
465
|
+
Args:
|
|
466
|
+
config: The configuration instance.
|
|
467
|
+
|
|
468
|
+
Returns:
|
|
469
|
+
The connection pool, an awaitable yielding the pool, or None if not supported.
|
|
470
|
+
"""
|
|
471
|
+
self._ensure_registered(config)
|
|
472
|
+
|
|
473
|
+
if config.supports_connection_pooling:
|
|
474
|
+
return cast("type[PoolT] | Awaitable[type[PoolT]]", config.create_pool())
|
|
475
|
+
return None
|
|
476
|
+
|
|
477
|
+
@overload
|
|
478
|
+
def close_pool(
|
|
479
|
+
self, config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT]"
|
|
480
|
+
) -> None: ...
|
|
481
|
+
@overload
|
|
482
|
+
def close_pool(
|
|
483
|
+
self, config: "NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]"
|
|
484
|
+
) -> "Awaitable[None]": ...
|
|
485
|
+
def close_pool(
|
|
486
|
+
self,
|
|
487
|
+
config: "NoPoolSyncConfig[ConnectionT, DriverT] | SyncDatabaseConfig[ConnectionT, PoolT, DriverT] | NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
488
|
+
) -> "Awaitable[None] | None":
|
|
489
|
+
"""Close the connection pool for the specified configuration.
|
|
490
|
+
|
|
491
|
+
Args:
|
|
492
|
+
config: The configuration instance.
|
|
493
|
+
|
|
494
|
+
Returns:
|
|
495
|
+
None, or an awaitable if closing an async pool.
|
|
496
|
+
"""
|
|
497
|
+
self._ensure_registered(config)
|
|
498
|
+
|
|
499
|
+
if config.supports_connection_pooling:
|
|
500
|
+
return config.close_pool()
|
|
501
|
+
return None
|
|
502
|
+
|
|
503
|
+
async def close_all_pools(self) -> None:
|
|
504
|
+
"""Explicitly close all connection pools (async and sync).
|
|
505
|
+
|
|
506
|
+
This method should be called before application shutdown for proper cleanup.
|
|
507
|
+
"""
|
|
508
|
+
cleanup_tasks = []
|
|
509
|
+
sync_configs: list[DatabaseConfigProtocol[Any, Any, Any]] = []
|
|
510
|
+
|
|
511
|
+
for config in tuple(self._configs.values()):
|
|
512
|
+
if config.supports_connection_pooling:
|
|
513
|
+
try:
|
|
514
|
+
if config.is_async:
|
|
515
|
+
close_pool_awaitable = config.close_pool()
|
|
516
|
+
if close_pool_awaitable is not None:
|
|
517
|
+
cleanup_tasks.append(cast("Coroutine[Any, Any, None]", close_pool_awaitable)) # pyright: ignore
|
|
518
|
+
else:
|
|
519
|
+
sync_configs.append(config) # pyright: ignore
|
|
520
|
+
except Exception as e:
|
|
521
|
+
logger.debug("Failed to prepare cleanup for config %s: %s", config.__class__.__name__, e)
|
|
522
|
+
|
|
523
|
+
async_failures: list[str] = []
|
|
524
|
+
if cleanup_tasks:
|
|
525
|
+
try:
|
|
526
|
+
await asyncio.gather(*cleanup_tasks, return_exceptions=True) # pyright: ignore
|
|
527
|
+
except Exception as e:
|
|
528
|
+
async_failures.append(str(e))
|
|
529
|
+
|
|
530
|
+
for config in sync_configs: # pyright: ignore
|
|
531
|
+
failure = self._safe_close_pool(config)
|
|
532
|
+
if failure is not None:
|
|
533
|
+
async_failures.append(failure)
|
|
534
|
+
|
|
535
|
+
if cleanup_tasks or sync_configs or async_failures:
|
|
536
|
+
summary: dict[str, object] = {
|
|
537
|
+
"async_pools": len(cleanup_tasks),
|
|
538
|
+
"sync_pools": len(sync_configs),
|
|
539
|
+
"failures": async_failures,
|
|
540
|
+
}
|
|
541
|
+
logger.debug("Pool cleanup completed.", extra=summary)
|
|
542
|
+
|
|
543
|
+
@overload
|
|
544
|
+
def event_channel(self, config: "type[SyncConfigT]") -> "SyncEventChannel": ...
|
|
545
|
+
@overload
|
|
546
|
+
def event_channel(self, config: "type[AsyncConfigT]") -> "AsyncEventChannel": ...
|
|
547
|
+
@overload
|
|
548
|
+
def event_channel(
|
|
549
|
+
self, config: "SyncDatabaseConfig[Any, Any, Any] | NoPoolSyncConfig[Any, Any]"
|
|
550
|
+
) -> "SyncEventChannel": ...
|
|
551
|
+
@overload
|
|
552
|
+
def event_channel(
|
|
553
|
+
self, config: "AsyncDatabaseConfig[Any, Any, Any] | NoPoolAsyncConfig[Any, Any]"
|
|
554
|
+
) -> "AsyncEventChannel": ...
|
|
555
|
+
def event_channel(
|
|
556
|
+
self,
|
|
557
|
+
config: "type[SyncConfigT | AsyncConfigT] | SyncDatabaseConfig[Any, Any, Any] | NoPoolSyncConfig[Any, Any] | AsyncDatabaseConfig[Any, Any, Any] | NoPoolAsyncConfig[Any, Any]",
|
|
558
|
+
) -> "SyncEventChannel | AsyncEventChannel":
|
|
559
|
+
"""Create an event channel for the provided configuration.
|
|
560
|
+
|
|
561
|
+
Returns SyncEventChannel for sync configs, AsyncEventChannel for async configs.
|
|
562
|
+
|
|
563
|
+
Args:
|
|
564
|
+
config: A registered database configuration instance or type.
|
|
565
|
+
|
|
566
|
+
Returns:
|
|
567
|
+
The appropriate event channel type for the configuration.
|
|
568
|
+
"""
|
|
569
|
+
if isinstance(config, type):
|
|
570
|
+
config_obj: DatabaseConfigProtocol[Any, Any, Any] | None = None
|
|
571
|
+
for registered_config in tuple(self._configs.values()):
|
|
572
|
+
if isinstance(registered_config, config):
|
|
573
|
+
config_obj = registered_config
|
|
574
|
+
break
|
|
575
|
+
if config_obj is None:
|
|
576
|
+
msg = f"Configuration {self._config_name(config)} is not registered"
|
|
577
|
+
raise ImproperConfigurationError(msg)
|
|
578
|
+
if config_obj.is_async:
|
|
579
|
+
return AsyncEventChannel(config_obj) # type: ignore[arg-type]
|
|
580
|
+
return SyncEventChannel(config_obj) # type: ignore[arg-type]
|
|
581
|
+
if config.is_async:
|
|
582
|
+
return AsyncEventChannel(config) # type: ignore[arg-type]
|
|
583
|
+
return SyncEventChannel(config) # type: ignore[arg-type]
|
|
584
|
+
|
|
585
|
+
def telemetry_snapshot(self) -> "dict[str, Any]":
|
|
586
|
+
"""Return aggregated diagnostics across all registered configurations."""
|
|
587
|
+
|
|
588
|
+
diagnostics = TelemetryDiagnostics()
|
|
589
|
+
loader_metrics = self._loader_runtime.metrics_snapshot()
|
|
590
|
+
if loader_metrics:
|
|
591
|
+
diagnostics.add_metric_snapshot(loader_metrics)
|
|
592
|
+
seen: set[int] = set()
|
|
593
|
+
configurations = tuple(self._configs.values())
|
|
594
|
+
for config in sorted(configurations, key=lambda item: not bool(item.replica_groups)):
|
|
595
|
+
self._collect_replica_telemetry(config, diagnostics, seen)
|
|
596
|
+
return diagnostics.snapshot()
|
|
597
|
+
|
|
598
|
+
@staticmethod
|
|
599
|
+
def get_cache_config() -> CacheConfig:
|
|
600
|
+
"""Get the current global cache configuration.
|
|
601
|
+
|
|
602
|
+
Returns:
|
|
603
|
+
The current cache configuration.
|
|
604
|
+
"""
|
|
605
|
+
return get_cache_config()
|
|
606
|
+
|
|
607
|
+
@staticmethod
|
|
608
|
+
def update_cache_config(config: CacheConfig) -> None:
|
|
609
|
+
"""Update the global cache configuration.
|
|
610
|
+
|
|
611
|
+
Args:
|
|
612
|
+
config: The new cache configuration to apply.
|
|
613
|
+
"""
|
|
614
|
+
update_cache_config(config)
|
|
615
|
+
|
|
616
|
+
@staticmethod
|
|
617
|
+
def get_cache_stats() -> "dict[str, Any]":
|
|
618
|
+
"""Get current cache statistics.
|
|
619
|
+
|
|
620
|
+
Returns:
|
|
621
|
+
Cache statistics object with detailed metrics.
|
|
622
|
+
"""
|
|
623
|
+
return get_cache_statistics()
|
|
624
|
+
|
|
625
|
+
@staticmethod
|
|
626
|
+
def reset_stats_only() -> None:
|
|
627
|
+
"""Reset cache statistics without clearing cached data."""
|
|
628
|
+
reset_stats_only()
|
|
629
|
+
|
|
630
|
+
@staticmethod
|
|
631
|
+
def log_cache_stats() -> None:
|
|
632
|
+
"""Log current cache statistics using the configured logger."""
|
|
633
|
+
log_cache_stats()
|
|
634
|
+
|
|
635
|
+
@staticmethod
|
|
636
|
+
def configure_cache(
|
|
637
|
+
*,
|
|
638
|
+
sql_cache_size: int | None = None,
|
|
639
|
+
fragment_cache_size: int | None = None,
|
|
640
|
+
optimized_cache_size: int | None = None,
|
|
641
|
+
compiled_cache_enabled: bool | None = None,
|
|
642
|
+
sql_cache_enabled: bool | None = None,
|
|
643
|
+
fragment_cache_enabled: bool | None = None,
|
|
644
|
+
optimized_cache_enabled: bool | None = None,
|
|
645
|
+
) -> None:
|
|
646
|
+
"""Update cache configuration with partial values.
|
|
647
|
+
|
|
648
|
+
Args:
|
|
649
|
+
sql_cache_size: Size of the statement/builder cache.
|
|
650
|
+
fragment_cache_size: Size of the expression/parameter/file cache.
|
|
651
|
+
optimized_cache_size: Size of the optimized expression cache.
|
|
652
|
+
compiled_cache_enabled: Master switch for namespaced and compiled SQL caches.
|
|
653
|
+
sql_cache_enabled: Enable/disable statement and builder cache.
|
|
654
|
+
fragment_cache_enabled: Enable/disable expression/parameter/file cache.
|
|
655
|
+
optimized_cache_enabled: Enable/disable optimized expression cache.
|
|
656
|
+
"""
|
|
657
|
+
current_config = get_cache_config()
|
|
658
|
+
update_cache_config(
|
|
659
|
+
CacheConfig(
|
|
660
|
+
compiled_cache_enabled=compiled_cache_enabled
|
|
661
|
+
if compiled_cache_enabled is not None
|
|
662
|
+
else current_config.compiled_cache_enabled,
|
|
663
|
+
sql_cache_size=sql_cache_size if sql_cache_size is not None else current_config.sql_cache_size,
|
|
664
|
+
fragment_cache_size=fragment_cache_size
|
|
665
|
+
if fragment_cache_size is not None
|
|
666
|
+
else current_config.fragment_cache_size,
|
|
667
|
+
optimized_cache_size=optimized_cache_size
|
|
668
|
+
if optimized_cache_size is not None
|
|
669
|
+
else current_config.optimized_cache_size,
|
|
670
|
+
sql_cache_enabled=sql_cache_enabled
|
|
671
|
+
if sql_cache_enabled is not None
|
|
672
|
+
else current_config.sql_cache_enabled,
|
|
673
|
+
fragment_cache_enabled=fragment_cache_enabled
|
|
674
|
+
if fragment_cache_enabled is not None
|
|
675
|
+
else current_config.fragment_cache_enabled,
|
|
676
|
+
optimized_cache_enabled=optimized_cache_enabled
|
|
677
|
+
if optimized_cache_enabled is not None
|
|
678
|
+
else current_config.optimized_cache_enabled,
|
|
679
|
+
)
|
|
680
|
+
)
|
|
681
|
+
|
|
682
|
+
def load_sql_files(self, *paths: "str | Path") -> None:
|
|
683
|
+
"""Load SQL files from paths or directories.
|
|
684
|
+
|
|
685
|
+
Args:
|
|
686
|
+
*paths: One or more file paths or directory paths to load.
|
|
687
|
+
"""
|
|
688
|
+
loader = self._ensure_loader()
|
|
689
|
+
loader.load_sql(*paths)
|
|
690
|
+
logger.debug("Loaded SQL files: %s", paths)
|
|
691
|
+
|
|
692
|
+
def add_named_sql(
|
|
693
|
+
self,
|
|
694
|
+
name: str,
|
|
695
|
+
sql: str,
|
|
696
|
+
dialect: "str | None" = None,
|
|
697
|
+
parameters: "Sequence[ParameterDeclaration] | None" = None,
|
|
698
|
+
) -> None:
|
|
699
|
+
"""Add a named SQL query directly.
|
|
700
|
+
|
|
701
|
+
Args:
|
|
702
|
+
name: Name for the SQL query.
|
|
703
|
+
sql: Raw SQL content.
|
|
704
|
+
dialect: Optional dialect for the SQL statement.
|
|
705
|
+
parameters: Optional declared parameter metadata for the query.
|
|
706
|
+
"""
|
|
707
|
+
loader = self._ensure_loader()
|
|
708
|
+
loader.add_named_sql(name, sql, dialect, parameters)
|
|
709
|
+
logger.debug("Added named SQL: %s", name)
|
|
710
|
+
|
|
711
|
+
def get_sql(self, name: str, **slots: Any) -> "SQL":
|
|
712
|
+
"""Get a SQL object by name, filling its slots.
|
|
713
|
+
|
|
714
|
+
Args:
|
|
715
|
+
name: Name of the statement from SQL file comments.
|
|
716
|
+
Hyphens in names are converted to underscores.
|
|
717
|
+
**slots: Values for the statement's ``/* slot: name */`` markers: a ``str``,
|
|
718
|
+
a sqlglot expression, or a ``SQL`` object whose named parameters are bound.
|
|
719
|
+
|
|
720
|
+
Returns:
|
|
721
|
+
SQL object ready for execution.
|
|
722
|
+
"""
|
|
723
|
+
return self._ensure_loader().get_sql(name, **slots)
|
|
724
|
+
|
|
725
|
+
def get_query_parameters(self, name: str) -> "tuple[ParameterDeclaration, ...]":
|
|
726
|
+
"""Get declared parameter metadata for a query.
|
|
727
|
+
|
|
728
|
+
Args:
|
|
729
|
+
name: Name of the statement from SQL file comments.
|
|
730
|
+
Hyphens in names are converted to underscores.
|
|
731
|
+
|
|
732
|
+
Returns:
|
|
733
|
+
Tuple of declared parameters; empty if the query declares none.
|
|
734
|
+
"""
|
|
735
|
+
return self._ensure_loader().get_query_parameters(name)
|
|
736
|
+
|
|
737
|
+
def list_sql_queries(self) -> "list[str]":
|
|
738
|
+
"""List all available query names.
|
|
739
|
+
|
|
740
|
+
Returns:
|
|
741
|
+
Sorted list of query names.
|
|
742
|
+
"""
|
|
743
|
+
if self._loader is None:
|
|
744
|
+
return []
|
|
745
|
+
return self._loader.list_queries()
|
|
746
|
+
|
|
747
|
+
def has_sql_query(self, name: str) -> bool:
|
|
748
|
+
"""Check if a SQL query exists.
|
|
749
|
+
|
|
750
|
+
Args:
|
|
751
|
+
name: Query name to check.
|
|
752
|
+
|
|
753
|
+
Returns:
|
|
754
|
+
True if the query exists in the loader.
|
|
755
|
+
"""
|
|
756
|
+
if self._loader is None:
|
|
757
|
+
return False
|
|
758
|
+
return self._loader.has_query(name)
|
|
759
|
+
|
|
760
|
+
def clear_sql_cache(self) -> None:
|
|
761
|
+
"""Clear the SQL file cache."""
|
|
762
|
+
if self._loader is not None:
|
|
763
|
+
self._loader.clear_cache()
|
|
764
|
+
logger.debug("Cleared SQL cache")
|
|
765
|
+
|
|
766
|
+
def reload_sql_files(self, *, reload: bool = False) -> None:
|
|
767
|
+
"""Reload all SQL files.
|
|
768
|
+
|
|
769
|
+
Args:
|
|
770
|
+
reload: Reload currently tracked files after clearing the cache.
|
|
771
|
+
"""
|
|
772
|
+
if self._loader is None:
|
|
773
|
+
return
|
|
774
|
+
if reload:
|
|
775
|
+
changed_files = self._loader._reload_changed_files()
|
|
776
|
+
logger.debug("Reloaded %d changed SQL files", len(changed_files))
|
|
777
|
+
return
|
|
778
|
+
self._loader.clear_cache()
|
|
779
|
+
logger.debug("Cleared SQL cache for reload")
|
|
780
|
+
|
|
781
|
+
def get_sql_files(self) -> "list[str]":
|
|
782
|
+
"""Get list of loaded SQL files.
|
|
783
|
+
|
|
784
|
+
Returns:
|
|
785
|
+
Sorted list of file paths.
|
|
786
|
+
"""
|
|
787
|
+
if self._loader is None:
|
|
788
|
+
return []
|
|
789
|
+
return self._loader.list_files()
|
|
790
|
+
|
|
791
|
+
@staticmethod
|
|
792
|
+
def _collect_replica_telemetry(
|
|
793
|
+
config: "DatabaseConfigProtocol[Any, Any, Any]", diagnostics: TelemetryDiagnostics, seen: set[int]
|
|
794
|
+
) -> None:
|
|
795
|
+
runtime = config.get_observability_runtime()
|
|
796
|
+
base_key = runtime.diagnostics_key
|
|
797
|
+
if id(config) not in seen:
|
|
798
|
+
seen.add(id(config))
|
|
799
|
+
diagnostics.add_lifecycle_snapshot(base_key, runtime.lifecycle_snapshot())
|
|
800
|
+
diagnostics.add_metric_snapshot(runtime.metrics_snapshot())
|
|
801
|
+
for group_name, group in config.replica_groups.items():
|
|
802
|
+
for index, replica in enumerate(group.configs):
|
|
803
|
+
if id(replica) in seen:
|
|
804
|
+
continue
|
|
805
|
+
seen.add(id(replica))
|
|
806
|
+
replica_runtime = replica.get_observability_runtime()
|
|
807
|
+
prefix = (
|
|
808
|
+
f"{base_key}:replica:{index}"
|
|
809
|
+
if group_name == "default"
|
|
810
|
+
else f"{base_key}:replica:{group_name}:{index}"
|
|
811
|
+
)
|
|
812
|
+
original_prefix = f"{replica_runtime.diagnostics_key}."
|
|
813
|
+
lifecycle = {
|
|
814
|
+
f"{prefix}.{key.removeprefix(original_prefix)}": value
|
|
815
|
+
for key, value in replica_runtime.lifecycle_snapshot().items()
|
|
816
|
+
}
|
|
817
|
+
metrics = {
|
|
818
|
+
f"{prefix}.{key.removeprefix(original_prefix)}": value
|
|
819
|
+
for key, value in replica_runtime.metrics_snapshot().items()
|
|
820
|
+
}
|
|
821
|
+
diagnostics.add_lifecycle_snapshot(prefix, lifecycle)
|
|
822
|
+
diagnostics.add_metric_snapshot(metrics)
|
|
823
|
+
|
|
824
|
+
def _ensure_registered(
|
|
825
|
+
self,
|
|
826
|
+
config: "NoPoolSyncConfig[Any, Any] | SyncDatabaseConfig[Any, Any, Any] | NoPoolAsyncConfig[Any, Any] | AsyncDatabaseConfig[Any, Any, Any]",
|
|
827
|
+
) -> None:
|
|
828
|
+
"""Register the configuration when it is not already tracked."""
|
|
829
|
+
if id(config) not in self._configs:
|
|
830
|
+
self.add_config(config)
|
|
831
|
+
|
|
832
|
+
def _ensure_loader(self) -> SQLFileLoader:
|
|
833
|
+
if self._loader is None:
|
|
834
|
+
self._loader = SQLFileLoader(runtime=self._loader_runtime)
|
|
835
|
+
return self._loader
|
|
836
|
+
|
|
837
|
+
async def _driver_from_async_connection(
|
|
838
|
+
self,
|
|
839
|
+
config: "NoPoolAsyncConfig[ConnectionT, DriverT] | AsyncDatabaseConfig[ConnectionT, PoolT, DriverT]",
|
|
840
|
+
connection_obj: "Awaitable[ConnectionT]",
|
|
841
|
+
) -> "DriverT":
|
|
842
|
+
resolved_connection = await connection_obj
|
|
843
|
+
driver = config.driver_type( # pyright: ignore
|
|
844
|
+
connection=resolved_connection,
|
|
845
|
+
statement_config=config.statement_config,
|
|
846
|
+
driver_features=config.driver_features,
|
|
847
|
+
)
|
|
848
|
+
return config._prepare_driver(driver) # pyright: ignore
|
|
849
|
+
|
|
850
|
+
@classmethod
|
|
851
|
+
def _cleanup_all_sync_pools(cls) -> None:
|
|
852
|
+
"""Walk every live SQLSpec and drain its sync pools at process exit."""
|
|
853
|
+
for instance in list(cls._live_instances):
|
|
854
|
+
instance._cleanup_sync_pools() # pyright: ignore[reportPrivateUsage]
|
|
855
|
+
|
|
856
|
+
def _cleanup_sync_pools(self) -> None:
|
|
857
|
+
"""Clean up only synchronous connection pools at exit."""
|
|
858
|
+
cleaned_count = 0
|
|
859
|
+
failed_configs: list[str] = []
|
|
860
|
+
|
|
861
|
+
for config in tuple(self._configs.values()):
|
|
862
|
+
if config.supports_connection_pooling and not config.is_async:
|
|
863
|
+
failure = self._safe_close_pool(config)
|
|
864
|
+
if failure is None:
|
|
865
|
+
cleaned_count += 1
|
|
866
|
+
else:
|
|
867
|
+
failed_configs.append(failure)
|
|
868
|
+
|
|
869
|
+
if cleaned_count or failed_configs:
|
|
870
|
+
summary: dict[str, object] = {"cleaned_pools": cleaned_count, "failed_pools": len(failed_configs)}
|
|
871
|
+
if failed_configs:
|
|
872
|
+
summary["failures"] = failed_configs
|
|
873
|
+
logger.debug("Sync pool cleanup completed.", extra=summary)
|
|
874
|
+
|
|
875
|
+
@staticmethod
|
|
876
|
+
def _safe_close_pool(config: "DatabaseConfigProtocol[Any, Any, Any]") -> "str | None":
|
|
877
|
+
"""Close a pool, returning an error string when it fails."""
|
|
878
|
+
try:
|
|
879
|
+
config.close_pool()
|
|
880
|
+
except Exception as exc: # pragma: no cover
|
|
881
|
+
return f"{config.__class__.__name__}: {exc}"
|
|
882
|
+
return None
|
|
883
|
+
|
|
884
|
+
@staticmethod
|
|
885
|
+
def _config_name(obj: Any) -> str:
|
|
886
|
+
"""Get display name for configuration object."""
|
|
887
|
+
if isinstance(obj, str):
|
|
888
|
+
return obj
|
|
889
|
+
if has_name(obj):
|
|
890
|
+
return obj.__name__
|
|
891
|
+
return type(obj).__name__
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
def coerce_sqlspec(
|
|
895
|
+
sqlspec: "SQLSpec | DatabaseConfigProtocol[Any, Any, Any] | Sequence[DatabaseConfigProtocol[Any, Any, Any]]",
|
|
896
|
+
*,
|
|
897
|
+
loader: "SQLFileLoader | None" = None,
|
|
898
|
+
) -> SQLSpec:
|
|
899
|
+
"""Normalize a SQLSpec registry, single config, or config sequence into SQLSpec.
|
|
900
|
+
|
|
901
|
+
Args:
|
|
902
|
+
sqlspec: Existing SQLSpec registry, a single database configuration, or a
|
|
903
|
+
sequence of database configurations.
|
|
904
|
+
loader: Optional SQL file loader attached when creating a registry or when
|
|
905
|
+
an existing registry has not initialized a loader yet.
|
|
906
|
+
|
|
907
|
+
Returns:
|
|
908
|
+
Normalized SQLSpec registry containing the provided configurations.
|
|
909
|
+
|
|
910
|
+
Raises:
|
|
911
|
+
ImproperConfigurationError: ``sqlspec`` is not a SQLSpec registry, database
|
|
912
|
+
configuration, or sequence of database configurations.
|
|
913
|
+
"""
|
|
914
|
+
if isinstance(sqlspec, SQLSpec):
|
|
915
|
+
if loader is not None and sqlspec._loader is None:
|
|
916
|
+
loader.set_observability_runtime(sqlspec._loader_runtime)
|
|
917
|
+
sqlspec._loader = loader
|
|
918
|
+
return sqlspec
|
|
919
|
+
if isinstance(sqlspec, DatabaseConfigProtocol):
|
|
920
|
+
registry = SQLSpec(loader=loader)
|
|
921
|
+
registry.add_config(cast("Any", sqlspec))
|
|
922
|
+
return registry
|
|
923
|
+
if isinstance(sqlspec, Sequence) and not isinstance(sqlspec, (str, bytes, bytearray)):
|
|
924
|
+
registry = SQLSpec(loader=loader)
|
|
925
|
+
for item in sqlspec:
|
|
926
|
+
if not isinstance(item, DatabaseConfigProtocol):
|
|
927
|
+
msg = (
|
|
928
|
+
"SQLSpecPlugin expects a SQLSpec instance, a database configuration, "
|
|
929
|
+
"or a sequence of database configurations"
|
|
930
|
+
)
|
|
931
|
+
raise ImproperConfigurationError(msg)
|
|
932
|
+
registry.add_config(cast("Any", item))
|
|
933
|
+
return registry
|
|
934
|
+
msg = "SQLSpecPlugin expects a SQLSpec instance, a database configuration, or a sequence of database configurations"
|
|
935
|
+
raise ImproperConfigurationError(msg)
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
def _is_async_context_manager(obj: Any) -> TypeGuard[AbstractAsyncContextManager[Any]]:
|
|
939
|
+
return isinstance(obj, AbstractAsyncContextManager)
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
943
|
+
class _RuntimeSyncContext(Generic[ContextValueT]):
|
|
944
|
+
__slots__ = ("_config", "_context", "_runtime", "_value")
|
|
945
|
+
|
|
946
|
+
def __init__(
|
|
947
|
+
self,
|
|
948
|
+
context: "AbstractContextManager[Any]",
|
|
949
|
+
runtime: "ObservabilityRuntime",
|
|
950
|
+
config: "DatabaseConfigProtocol[Any, Any, Any] | None" = None,
|
|
951
|
+
) -> None:
|
|
952
|
+
self._context = context
|
|
953
|
+
self._runtime = runtime
|
|
954
|
+
self._config = config
|
|
955
|
+
self._value: Any | None = None
|
|
956
|
+
|
|
957
|
+
def __enter__(self) -> ContextValueT:
|
|
958
|
+
value = self._context.__enter__()
|
|
959
|
+
config = self._config
|
|
960
|
+
if config is not None:
|
|
961
|
+
driver: Any = None
|
|
962
|
+
raw_connection: Any | None = None
|
|
963
|
+
connection_created = False
|
|
964
|
+
try:
|
|
965
|
+
prepared: Any = (
|
|
966
|
+
value
|
|
967
|
+
if getattr(value, "_observability", None) is self._runtime
|
|
968
|
+
else cast("Any", config)._prepare_driver(value)
|
|
969
|
+
)
|
|
970
|
+
driver = prepared
|
|
971
|
+
raw_connection = prepared.connection
|
|
972
|
+
if raw_connection is not None and raw_connection is not _CLOSED_CONNECTION:
|
|
973
|
+
self._runtime.emit_connection_create_sync(raw_connection)
|
|
974
|
+
connection_created = True
|
|
975
|
+
self._runtime.emit_session_start_sync(prepared)
|
|
976
|
+
except BaseException as exc:
|
|
977
|
+
self._value = None
|
|
978
|
+
try:
|
|
979
|
+
try:
|
|
980
|
+
self._context.__exit__(type(exc), exc, exc.__traceback__)
|
|
981
|
+
finally:
|
|
982
|
+
if (
|
|
983
|
+
connection_created
|
|
984
|
+
and raw_connection is not None
|
|
985
|
+
and raw_connection is not _CLOSED_CONNECTION
|
|
986
|
+
):
|
|
987
|
+
self._runtime.emit_connection_destroy_sync(raw_connection)
|
|
988
|
+
finally:
|
|
989
|
+
if driver is not None:
|
|
990
|
+
driver._mark_closed()
|
|
991
|
+
raise
|
|
992
|
+
self._value = prepared
|
|
993
|
+
return cast("ContextValueT", prepared)
|
|
994
|
+
|
|
995
|
+
try:
|
|
996
|
+
self._runtime.emit_connection_create_sync(value)
|
|
997
|
+
except BaseException as exc:
|
|
998
|
+
self._value = None
|
|
999
|
+
self._context.__exit__(type(exc), exc, exc.__traceback__)
|
|
1000
|
+
raise
|
|
1001
|
+
self._value = value
|
|
1002
|
+
return cast("ContextValueT", value)
|
|
1003
|
+
|
|
1004
|
+
def __exit__(
|
|
1005
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
1006
|
+
) -> "bool | None":
|
|
1007
|
+
value = self._value
|
|
1008
|
+
raw_connection = value.connection if value is not None and self._config is not None else None
|
|
1009
|
+
try:
|
|
1010
|
+
return self._context.__exit__(exc_type, exc_val, exc_tb)
|
|
1011
|
+
finally:
|
|
1012
|
+
self._value = None
|
|
1013
|
+
if value is not None:
|
|
1014
|
+
if self._config is None:
|
|
1015
|
+
if value is not _CLOSED_CONNECTION:
|
|
1016
|
+
self._runtime.emit_connection_destroy_sync(value)
|
|
1017
|
+
else:
|
|
1018
|
+
try:
|
|
1019
|
+
try:
|
|
1020
|
+
self._runtime.emit_session_end_sync(value)
|
|
1021
|
+
finally:
|
|
1022
|
+
if raw_connection is not None and raw_connection is not _CLOSED_CONNECTION:
|
|
1023
|
+
self._runtime.emit_connection_destroy_sync(raw_connection)
|
|
1024
|
+
finally:
|
|
1025
|
+
if value.connection is not _CLOSED_CONNECTION:
|
|
1026
|
+
value._mark_closed()
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1030
|
+
class _RuntimeAsyncContext(Generic[ContextValueT]):
|
|
1031
|
+
__slots__ = ("_config", "_context", "_runtime", "_value")
|
|
1032
|
+
|
|
1033
|
+
def __init__(
|
|
1034
|
+
self,
|
|
1035
|
+
context: "AbstractAsyncContextManager[Any]",
|
|
1036
|
+
runtime: "ObservabilityRuntime",
|
|
1037
|
+
config: "DatabaseConfigProtocol[Any, Any, Any] | None" = None,
|
|
1038
|
+
) -> None:
|
|
1039
|
+
self._context = context
|
|
1040
|
+
self._runtime = runtime
|
|
1041
|
+
self._config = config
|
|
1042
|
+
self._value: Any | None = None
|
|
1043
|
+
|
|
1044
|
+
async def __aenter__(self) -> ContextValueT:
|
|
1045
|
+
value = await self._context.__aenter__()
|
|
1046
|
+
config = self._config
|
|
1047
|
+
if config is not None:
|
|
1048
|
+
driver: Any = None
|
|
1049
|
+
raw_connection: Any | None = None
|
|
1050
|
+
connection_created = False
|
|
1051
|
+
enter_error: BaseException | None = None
|
|
1052
|
+
prepared: Any = None
|
|
1053
|
+
try:
|
|
1054
|
+
prepared = (
|
|
1055
|
+
value
|
|
1056
|
+
if getattr(value, "_observability", None) is self._runtime
|
|
1057
|
+
else cast("Any", config)._prepare_driver(value)
|
|
1058
|
+
)
|
|
1059
|
+
driver = prepared
|
|
1060
|
+
raw_connection = prepared.connection
|
|
1061
|
+
if raw_connection is not None and raw_connection is not _CLOSED_CONNECTION:
|
|
1062
|
+
await self._runtime.emit_connection_create_async(raw_connection)
|
|
1063
|
+
connection_created = True
|
|
1064
|
+
await self._runtime.emit_session_start_async(prepared)
|
|
1065
|
+
except BaseException as exc:
|
|
1066
|
+
enter_error = exc
|
|
1067
|
+
if enter_error is not None:
|
|
1068
|
+
self._value = None
|
|
1069
|
+
try:
|
|
1070
|
+
await self._context.__aexit__(type(enter_error), enter_error, enter_error.__traceback__)
|
|
1071
|
+
except BaseException as exc:
|
|
1072
|
+
enter_error = exc
|
|
1073
|
+
if connection_created and raw_connection is not None and raw_connection is not _CLOSED_CONNECTION:
|
|
1074
|
+
try:
|
|
1075
|
+
await self._runtime.emit_connection_destroy_async(raw_connection)
|
|
1076
|
+
except BaseException as exc:
|
|
1077
|
+
enter_error = exc
|
|
1078
|
+
if driver is not None:
|
|
1079
|
+
driver._mark_closed()
|
|
1080
|
+
raise enter_error
|
|
1081
|
+
self._value = prepared
|
|
1082
|
+
return cast("ContextValueT", prepared)
|
|
1083
|
+
|
|
1084
|
+
create_error: BaseException | None = None
|
|
1085
|
+
try:
|
|
1086
|
+
await self._runtime.emit_connection_create_async(value)
|
|
1087
|
+
except BaseException as exc:
|
|
1088
|
+
create_error = exc
|
|
1089
|
+
if create_error is not None:
|
|
1090
|
+
self._value = None
|
|
1091
|
+
await self._context.__aexit__(type(create_error), create_error, create_error.__traceback__)
|
|
1092
|
+
raise create_error
|
|
1093
|
+
self._value = value
|
|
1094
|
+
return cast("ContextValueT", value)
|
|
1095
|
+
|
|
1096
|
+
async def __aexit__(
|
|
1097
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
1098
|
+
) -> "bool | None":
|
|
1099
|
+
value = self._value
|
|
1100
|
+
raw_connection = value.connection if value is not None and self._config is not None else None
|
|
1101
|
+
exit_error: BaseException | None = None
|
|
1102
|
+
suppressed: bool | None = None
|
|
1103
|
+
try:
|
|
1104
|
+
suppressed = await self._context.__aexit__(exc_type, exc_val, exc_tb)
|
|
1105
|
+
except BaseException as exc:
|
|
1106
|
+
exit_error = exc
|
|
1107
|
+
self._value = None
|
|
1108
|
+
if value is not None:
|
|
1109
|
+
if self._config is None:
|
|
1110
|
+
if value is not _CLOSED_CONNECTION:
|
|
1111
|
+
await self._runtime.emit_connection_destroy_async(value)
|
|
1112
|
+
else:
|
|
1113
|
+
try:
|
|
1114
|
+
await self._runtime.emit_session_end_async(value)
|
|
1115
|
+
except BaseException as exc:
|
|
1116
|
+
exit_error = exc
|
|
1117
|
+
if raw_connection is not None and raw_connection is not _CLOSED_CONNECTION:
|
|
1118
|
+
try:
|
|
1119
|
+
await self._runtime.emit_connection_destroy_async(raw_connection)
|
|
1120
|
+
except BaseException as exc:
|
|
1121
|
+
exit_error = exc
|
|
1122
|
+
if value.connection is not _CLOSED_CONNECTION:
|
|
1123
|
+
value._mark_closed()
|
|
1124
|
+
if exit_error is not None:
|
|
1125
|
+
raise exit_error
|
|
1126
|
+
return suppressed
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1130
|
+
class _RuntimeReadSyncContext(Generic[ContextValueT]):
|
|
1131
|
+
__slots__ = ("_context", "_runtime", "_session", "_value")
|
|
1132
|
+
|
|
1133
|
+
def __init__(self, context: "AbstractContextManager[Any]", *, session: bool = False) -> None:
|
|
1134
|
+
self._context = context
|
|
1135
|
+
self._session = session
|
|
1136
|
+
self._runtime: ObservabilityRuntime | None = None
|
|
1137
|
+
self._value: Any = None
|
|
1138
|
+
|
|
1139
|
+
def __enter__(self) -> ContextValueT:
|
|
1140
|
+
value = self._context.__enter__()
|
|
1141
|
+
receipt = getattr(self._context, "_selection_receipt", None)
|
|
1142
|
+
selected = getattr(receipt, "config", None)
|
|
1143
|
+
if selected is None:
|
|
1144
|
+
error = ImproperConfigurationError("Read provider did not publish the selected configuration")
|
|
1145
|
+
self._context.__exit__(type(error), error, error.__traceback__)
|
|
1146
|
+
raise error
|
|
1147
|
+
runtime = selected.get_observability_runtime()
|
|
1148
|
+
connection = value.connection if self._session else value
|
|
1149
|
+
connection_created = False
|
|
1150
|
+
try:
|
|
1151
|
+
if connection is not None and connection is not _CLOSED_CONNECTION:
|
|
1152
|
+
runtime.emit_connection_create_sync(connection)
|
|
1153
|
+
connection_created = True
|
|
1154
|
+
if self._session:
|
|
1155
|
+
runtime.emit_session_start_sync(value)
|
|
1156
|
+
except BaseException as exc:
|
|
1157
|
+
self._value = None
|
|
1158
|
+
self._runtime = None
|
|
1159
|
+
try:
|
|
1160
|
+
try:
|
|
1161
|
+
self._context.__exit__(type(exc), exc, exc.__traceback__)
|
|
1162
|
+
finally:
|
|
1163
|
+
if connection_created and connection is not None and connection is not _CLOSED_CONNECTION:
|
|
1164
|
+
runtime.emit_connection_destroy_sync(connection)
|
|
1165
|
+
finally:
|
|
1166
|
+
if self._session and value.connection is not _CLOSED_CONNECTION:
|
|
1167
|
+
value._mark_closed()
|
|
1168
|
+
raise
|
|
1169
|
+
self._runtime = runtime
|
|
1170
|
+
self._value = value
|
|
1171
|
+
return cast("ContextValueT", value)
|
|
1172
|
+
|
|
1173
|
+
def __exit__(
|
|
1174
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
1175
|
+
) -> "bool | None":
|
|
1176
|
+
value = self._value
|
|
1177
|
+
runtime = self._runtime
|
|
1178
|
+
connection = value.connection if self._session and value is not None else value
|
|
1179
|
+
try:
|
|
1180
|
+
return self._context.__exit__(exc_type, exc_val, exc_tb)
|
|
1181
|
+
finally:
|
|
1182
|
+
self._value = None
|
|
1183
|
+
self._runtime = None
|
|
1184
|
+
try:
|
|
1185
|
+
if runtime is not None:
|
|
1186
|
+
try:
|
|
1187
|
+
if self._session and value is not None:
|
|
1188
|
+
runtime.emit_session_end_sync(value)
|
|
1189
|
+
finally:
|
|
1190
|
+
if connection is not None and connection is not _CLOSED_CONNECTION:
|
|
1191
|
+
runtime.emit_connection_destroy_sync(connection)
|
|
1192
|
+
finally:
|
|
1193
|
+
if self._session and value is not None and value.connection is not _CLOSED_CONNECTION:
|
|
1194
|
+
value._mark_closed()
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1198
|
+
class _RuntimeReadAsyncContext(Generic[ContextValueT]):
|
|
1199
|
+
__slots__ = ("_context", "_runtime", "_session", "_value")
|
|
1200
|
+
|
|
1201
|
+
def __init__(self, context: "AbstractAsyncContextManager[Any]", *, session: bool = False) -> None:
|
|
1202
|
+
self._context = context
|
|
1203
|
+
self._session = session
|
|
1204
|
+
self._runtime: ObservabilityRuntime | None = None
|
|
1205
|
+
self._value: Any = None
|
|
1206
|
+
|
|
1207
|
+
async def __aenter__(self) -> ContextValueT:
|
|
1208
|
+
value = await self._context.__aenter__()
|
|
1209
|
+
receipt = getattr(self._context, "_selection_receipt", None)
|
|
1210
|
+
selected = getattr(receipt, "config", None)
|
|
1211
|
+
if selected is None:
|
|
1212
|
+
error = ImproperConfigurationError("Read provider did not publish the selected configuration")
|
|
1213
|
+
await self._context.__aexit__(type(error), error, error.__traceback__)
|
|
1214
|
+
raise error
|
|
1215
|
+
runtime = selected.get_observability_runtime()
|
|
1216
|
+
connection = value.connection if self._session else value
|
|
1217
|
+
connection_created = False
|
|
1218
|
+
enter_error: BaseException | None = None
|
|
1219
|
+
try:
|
|
1220
|
+
if connection is not None and connection is not _CLOSED_CONNECTION:
|
|
1221
|
+
await runtime.emit_connection_create_async(connection)
|
|
1222
|
+
connection_created = True
|
|
1223
|
+
if self._session:
|
|
1224
|
+
await runtime.emit_session_start_async(value)
|
|
1225
|
+
except BaseException as exc:
|
|
1226
|
+
enter_error = exc
|
|
1227
|
+
if enter_error is not None:
|
|
1228
|
+
self._value = None
|
|
1229
|
+
self._runtime = None
|
|
1230
|
+
try:
|
|
1231
|
+
await self._context.__aexit__(type(enter_error), enter_error, enter_error.__traceback__)
|
|
1232
|
+
except BaseException as exc:
|
|
1233
|
+
enter_error = exc
|
|
1234
|
+
if connection_created and connection is not None and connection is not _CLOSED_CONNECTION:
|
|
1235
|
+
try:
|
|
1236
|
+
await runtime.emit_connection_destroy_async(connection)
|
|
1237
|
+
except BaseException as exc:
|
|
1238
|
+
enter_error = exc
|
|
1239
|
+
if self._session and value.connection is not _CLOSED_CONNECTION:
|
|
1240
|
+
value._mark_closed()
|
|
1241
|
+
raise enter_error
|
|
1242
|
+
self._runtime = runtime
|
|
1243
|
+
self._value = value
|
|
1244
|
+
return cast("ContextValueT", value)
|
|
1245
|
+
|
|
1246
|
+
async def __aexit__(
|
|
1247
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
1248
|
+
) -> "bool | None":
|
|
1249
|
+
value = self._value
|
|
1250
|
+
runtime = self._runtime
|
|
1251
|
+
connection = value.connection if self._session and value is not None else value
|
|
1252
|
+
exit_error: BaseException | None = None
|
|
1253
|
+
suppressed: bool | None = None
|
|
1254
|
+
try:
|
|
1255
|
+
suppressed = await self._context.__aexit__(exc_type, exc_val, exc_tb)
|
|
1256
|
+
except BaseException as exc:
|
|
1257
|
+
exit_error = exc
|
|
1258
|
+
self._value = None
|
|
1259
|
+
self._runtime = None
|
|
1260
|
+
if runtime is not None:
|
|
1261
|
+
if self._session and value is not None:
|
|
1262
|
+
try:
|
|
1263
|
+
await runtime.emit_session_end_async(value)
|
|
1264
|
+
except BaseException as exc:
|
|
1265
|
+
exit_error = exc
|
|
1266
|
+
if connection is not None and connection is not _CLOSED_CONNECTION:
|
|
1267
|
+
try:
|
|
1268
|
+
await runtime.emit_connection_destroy_async(connection)
|
|
1269
|
+
except BaseException as exc:
|
|
1270
|
+
exit_error = exc
|
|
1271
|
+
if self._session and value is not None and value.connection is not _CLOSED_CONNECTION:
|
|
1272
|
+
value._mark_closed()
|
|
1273
|
+
if exit_error is not None:
|
|
1274
|
+
raise exit_error
|
|
1275
|
+
return suppressed
|