sqlspec 0.72.0__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 6b29784d6b1cafc66758__mypyc.cp315-win_amd64.pyd +0 -0
- sqlspec/__init__.py +381 -0
- sqlspec/__main__.py +14 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_typing.py +775 -0
- sqlspec/adapters/__init__.py +3 -0
- sqlspec/adapters/adbc/__init__.py +16 -0
- sqlspec/adapters/adbc/_typing.py +221 -0
- sqlspec/adapters/adbc/adk/__init__.py +11 -0
- sqlspec/adapters/adbc/adk/store.py +4101 -0
- sqlspec/adapters/adbc/config.py +843 -0
- sqlspec/adapters/adbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/core.py +3209 -0
- sqlspec/adapters/adbc/data_dictionary.py +1448 -0
- sqlspec/adapters/adbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/driver.py +1400 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +384 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +962 -0
- sqlspec/adapters/adbc/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/pool.py +242 -0
- sqlspec/adapters/adbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/type_converter.py +117 -0
- sqlspec/adapters/aiomysql/__init__.py +25 -0
- sqlspec/adapters/aiomysql/_typing.py +134 -0
- sqlspec/adapters/aiomysql/adk/__init__.py +5 -0
- sqlspec/adapters/aiomysql/adk/store.py +1542 -0
- sqlspec/adapters/aiomysql/config.py +634 -0
- sqlspec/adapters/aiomysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/core.py +922 -0
- sqlspec/adapters/aiomysql/data_dictionary.py +16 -0
- sqlspec/adapters/aiomysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/driver.py +494 -0
- sqlspec/adapters/aiomysql/events/__init__.py +5 -0
- sqlspec/adapters/aiomysql/events/store.py +72 -0
- sqlspec/adapters/aiomysql/litestar/__init__.py +5 -0
- sqlspec/adapters/aiomysql/litestar/store.py +345 -0
- sqlspec/adapters/aiosqlite/__init__.py +43 -0
- sqlspec/adapters/aiosqlite/_typing.py +75 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +1546 -0
- sqlspec/adapters/aiosqlite/config.py +607 -0
- sqlspec/adapters/aiosqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/core.py +1155 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +343 -0
- sqlspec/adapters/aiosqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/driver.py +559 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +54 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +315 -0
- sqlspec/adapters/aiosqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/pool.py +1323 -0
- sqlspec/adapters/aiosqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/type_converter.py +114 -0
- sqlspec/adapters/arrow_odbc/__init__.py +32 -0
- sqlspec/adapters/arrow_odbc/_typing.py +131 -0
- sqlspec/adapters/arrow_odbc/adk/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/adk/store.py +1671 -0
- sqlspec/adapters/arrow_odbc/config.py +446 -0
- sqlspec/adapters/arrow_odbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/core.py +795 -0
- sqlspec/adapters/arrow_odbc/data_dictionary.py +345 -0
- sqlspec/adapters/arrow_odbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/driver.py +885 -0
- sqlspec/adapters/arrow_odbc/events/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/events/store.py +114 -0
- sqlspec/adapters/arrow_odbc/litestar/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/litestar/store.py +682 -0
- sqlspec/adapters/arrow_odbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/type_converter.py +95 -0
- sqlspec/adapters/asyncmy/__init__.py +27 -0
- sqlspec/adapters/asyncmy/_typing.py +215 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +1544 -0
- sqlspec/adapters/asyncmy/config.py +707 -0
- sqlspec/adapters/asyncmy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/core.py +917 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +16 -0
- sqlspec/adapters/asyncmy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/driver.py +529 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +72 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +348 -0
- sqlspec/adapters/asyncpg/__init__.py +28 -0
- sqlspec/adapters/asyncpg/_typing.py +113 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +1145 -0
- sqlspec/adapters/asyncpg/config.py +903 -0
- sqlspec/adapters/asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/core.py +797 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +417 -0
- sqlspec/adapters/asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/driver.py +927 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/events/_hub.py +279 -0
- sqlspec/adapters/asyncpg/events/backend.py +410 -0
- sqlspec/adapters/asyncpg/events/store.py +57 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +278 -0
- sqlspec/adapters/asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/tenant.py +140 -0
- sqlspec/adapters/bigquery/__init__.py +23 -0
- sqlspec/adapters/bigquery/_typing.py +184 -0
- sqlspec/adapters/bigquery/adk/__init__.py +5 -0
- sqlspec/adapters/bigquery/adk/store.py +920 -0
- sqlspec/adapters/bigquery/config.py +631 -0
- sqlspec/adapters/bigquery/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/core.py +1433 -0
- sqlspec/adapters/bigquery/data_dictionary.py +502 -0
- sqlspec/adapters/bigquery/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/driver.py +1266 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +158 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +359 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +32 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +54 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +9 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +1096 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +653 -0
- sqlspec/adapters/cockroach_asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +835 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +371 -0
- sqlspec/adapters/cockroach_asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +438 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +203 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.py +143 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +46 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +271 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +2274 -0
- sqlspec/adapters/cockroach_psycopg/config.py +1285 -0
- sqlspec/adapters/cockroach_psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +667 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +622 -0
- sqlspec/adapters/cockroach_psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +864 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +8 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +9 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +413 -0
- sqlspec/adapters/cockroach_psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/tenant.py +222 -0
- sqlspec/adapters/db2/__init__.py +34 -0
- sqlspec/adapters/db2/_typing.py +357 -0
- sqlspec/adapters/db2/adk/__init__.py +10 -0
- sqlspec/adapters/db2/adk/store.py +1950 -0
- sqlspec/adapters/db2/config.py +550 -0
- sqlspec/adapters/db2/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/core.py +1021 -0
- sqlspec/adapters/db2/data_dictionary.py +493 -0
- sqlspec/adapters/db2/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/driver.py +898 -0
- sqlspec/adapters/db2/events/__init__.py +5 -0
- sqlspec/adapters/db2/events/store.py +77 -0
- sqlspec/adapters/db2/litestar/__init__.py +5 -0
- sqlspec/adapters/db2/litestar/store.py +519 -0
- sqlspec/adapters/db2/migrations.py +221 -0
- sqlspec/adapters/db2/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/pool.py +876 -0
- sqlspec/adapters/db2/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/tenant.py +292 -0
- sqlspec/adapters/duckdb/__init__.py +30 -0
- sqlspec/adapters/duckdb/_typing.py +182 -0
- sqlspec/adapters/duckdb/adk/__init__.py +10 -0
- sqlspec/adapters/duckdb/adk/store.py +1672 -0
- sqlspec/adapters/duckdb/config.py +506 -0
- sqlspec/adapters/duckdb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/core.py +1299 -0
- sqlspec/adapters/duckdb/data_dictionary.py +553 -0
- sqlspec/adapters/duckdb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/driver.py +1214 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +38 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +313 -0
- sqlspec/adapters/duckdb/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/pool.py +1121 -0
- sqlspec/adapters/mssql_python/__init__.py +42 -0
- sqlspec/adapters/mssql_python/_typing.py +135 -0
- sqlspec/adapters/mssql_python/adk/__init__.py +5 -0
- sqlspec/adapters/mssql_python/adk/store.py +1278 -0
- sqlspec/adapters/mssql_python/config.py +455 -0
- sqlspec/adapters/mssql_python/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/core.py +862 -0
- sqlspec/adapters/mssql_python/data_dictionary.py +417 -0
- sqlspec/adapters/mssql_python/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/driver.py +772 -0
- sqlspec/adapters/mssql_python/events/__init__.py +5 -0
- sqlspec/adapters/mssql_python/events/store.py +46 -0
- sqlspec/adapters/mssql_python/litestar/__init__.py +5 -0
- sqlspec/adapters/mssql_python/litestar/store.py +355 -0
- sqlspec/adapters/mssql_python/migrations.py +162 -0
- sqlspec/adapters/mssql_python/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/pool.py +165 -0
- sqlspec/adapters/mssql_python/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/tenant.py +74 -0
- sqlspec/adapters/mssql_python/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/type_converter.py +98 -0
- sqlspec/adapters/mysqlconnector/__init__.py +47 -0
- sqlspec/adapters/mysqlconnector/_typing.py +205 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +17 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +2503 -0
- sqlspec/adapters/mysqlconnector/config.py +925 -0
- sqlspec/adapters/mysqlconnector/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/core.py +1075 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +23 -0
- sqlspec/adapters/mysqlconnector/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/driver.py +702 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +89 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +9 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +524 -0
- sqlspec/adapters/oracledb/__init__.py +159 -0
- sqlspec/adapters/oracledb/_json_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_json_handlers.py +208 -0
- sqlspec/adapters/oracledb/_param_types.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_param_types.py +65 -0
- sqlspec/adapters/oracledb/_plugins.py +137 -0
- sqlspec/adapters/oracledb/_storage.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_storage.py +138 -0
- sqlspec/adapters/oracledb/_typing.py +468 -0
- sqlspec/adapters/oracledb/_uuid_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +143 -0
- sqlspec/adapters/oracledb/_vector_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_vector_handlers.py +252 -0
- sqlspec/adapters/oracledb/adk/__init__.py +27 -0
- sqlspec/adapters/oracledb/adk/store.py +4031 -0
- sqlspec/adapters/oracledb/config.py +1785 -0
- sqlspec/adapters/oracledb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/core.py +5416 -0
- sqlspec/adapters/oracledb/data_dictionary.py +1264 -0
- sqlspec/adapters/oracledb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/driver.py +3273 -0
- sqlspec/adapters/oracledb/events/__init__.py +29 -0
- sqlspec/adapters/oracledb/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/events/_hub.py +394 -0
- sqlspec/adapters/oracledb/events/backend.py +311 -0
- sqlspec/adapters/oracledb/events/store.py +842 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +17 -0
- sqlspec/adapters/oracledb/litestar/store.py +862 -0
- sqlspec/adapters/oracledb/migrations.py +650 -0
- sqlspec/adapters/oracledb/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/tenant.py +990 -0
- sqlspec/adapters/oracledb/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/type_converter.py +93 -0
- sqlspec/adapters/psqlpy/__init__.py +21 -0
- sqlspec/adapters/psqlpy/_typing.py +180 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +1514 -0
- sqlspec/adapters/psqlpy/config.py +828 -0
- sqlspec/adapters/psqlpy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/core.py +1040 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +399 -0
- sqlspec/adapters/psqlpy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/driver.py +631 -0
- sqlspec/adapters/psqlpy/events/__init__.py +12 -0
- sqlspec/adapters/psqlpy/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/events/_hub.py +367 -0
- sqlspec/adapters/psqlpy/events/backend.py +415 -0
- sqlspec/adapters/psqlpy/events/store.py +46 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/tenant.py +137 -0
- sqlspec/adapters/psqlpy/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +21 -0
- sqlspec/adapters/psycopg/__init__.py +44 -0
- sqlspec/adapters/psycopg/_typing.py +408 -0
- sqlspec/adapters/psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/psycopg/adk/store.py +2761 -0
- sqlspec/adapters/psycopg/config.py +1522 -0
- sqlspec/adapters/psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/core.py +1001 -0
- sqlspec/adapters/psycopg/data_dictionary.py +701 -0
- sqlspec/adapters/psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/driver.py +1629 -0
- sqlspec/adapters/psycopg/events/__init__.py +25 -0
- sqlspec/adapters/psycopg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/events/_hub.py +646 -0
- sqlspec/adapters/psycopg/events/backend.py +739 -0
- sqlspec/adapters/psycopg/events/store.py +82 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +595 -0
- sqlspec/adapters/psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/tenant.py +226 -0
- sqlspec/adapters/psycopg/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/type_converter.py +94 -0
- sqlspec/adapters/pymssql/__init__.py +29 -0
- sqlspec/adapters/pymssql/_typing.py +156 -0
- sqlspec/adapters/pymssql/adk/__init__.py +5 -0
- sqlspec/adapters/pymssql/adk/store.py +1270 -0
- sqlspec/adapters/pymssql/config.py +299 -0
- sqlspec/adapters/pymssql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/core.py +527 -0
- sqlspec/adapters/pymssql/data_dictionary.py +417 -0
- sqlspec/adapters/pymssql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/driver.py +527 -0
- sqlspec/adapters/pymssql/events/__init__.py +5 -0
- sqlspec/adapters/pymssql/events/store.py +46 -0
- sqlspec/adapters/pymssql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymssql/litestar/store.py +350 -0
- sqlspec/adapters/pymssql/migrations.py +162 -0
- sqlspec/adapters/pymssql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/pool.py +417 -0
- sqlspec/adapters/pymssql/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/tenant.py +73 -0
- sqlspec/adapters/pymysql/__init__.py +27 -0
- sqlspec/adapters/pymysql/_typing.py +105 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +1646 -0
- sqlspec/adapters/pymysql/config.py +545 -0
- sqlspec/adapters/pymysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/core.py +909 -0
- sqlspec/adapters/pymysql/data_dictionary.py +16 -0
- sqlspec/adapters/pymysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/driver.py +370 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +42 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +299 -0
- sqlspec/adapters/pymysql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/pool.py +480 -0
- sqlspec/adapters/snowflake/__init__.py +36 -0
- sqlspec/adapters/snowflake/_typing.py +62 -0
- sqlspec/adapters/snowflake/adk/__init__.py +5 -0
- sqlspec/adapters/snowflake/adk/store.py +778 -0
- sqlspec/adapters/snowflake/config.py +333 -0
- sqlspec/adapters/snowflake/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/core.py +683 -0
- sqlspec/adapters/snowflake/data_dictionary.py +355 -0
- sqlspec/adapters/snowflake/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/driver.py +872 -0
- sqlspec/adapters/snowflake/events/__init__.py +5 -0
- sqlspec/adapters/snowflake/events/store.py +28 -0
- sqlspec/adapters/snowflake/litestar/__init__.py +5 -0
- sqlspec/adapters/snowflake/litestar/store.py +162 -0
- sqlspec/adapters/snowflake/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/migrations.py +76 -0
- sqlspec/adapters/snowflake/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/pool.py +385 -0
- sqlspec/adapters/snowflake/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/tenant.py +200 -0
- sqlspec/adapters/snowflake/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/type_converter.py +33 -0
- sqlspec/adapters/spanner/__init__.py +57 -0
- sqlspec/adapters/spanner/_typing.py +300 -0
- sqlspec/adapters/spanner/adk/__init__.py +22 -0
- sqlspec/adapters/spanner/adk/artifact_store.py +693 -0
- sqlspec/adapters/spanner/adk/store.py +3053 -0
- sqlspec/adapters/spanner/config.py +1578 -0
- sqlspec/adapters/spanner/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/core.py +1244 -0
- sqlspec/adapters/spanner/data_dictionary.py +706 -0
- sqlspec/adapters/spanner/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/driver.py +1673 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +357 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +570 -0
- sqlspec/adapters/spanner/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/type_converter.py +466 -0
- sqlspec/adapters/sqlanywhere/__init__.py +40 -0
- sqlspec/adapters/sqlanywhere/_typing.py +139 -0
- sqlspec/adapters/sqlanywhere/adk/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/adk/store.py +1136 -0
- sqlspec/adapters/sqlanywhere/config.py +359 -0
- sqlspec/adapters/sqlanywhere/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/core.py +583 -0
- sqlspec/adapters/sqlanywhere/data_dictionary.py +282 -0
- sqlspec/adapters/sqlanywhere/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/driver.py +480 -0
- sqlspec/adapters/sqlanywhere/events/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/events/store.py +28 -0
- sqlspec/adapters/sqlanywhere/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/litestar/store.py +237 -0
- sqlspec/adapters/sqlanywhere/migrations.py +178 -0
- sqlspec/adapters/sqlanywhere/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/pool.py +397 -0
- sqlspec/adapters/sqlite/__init__.py +32 -0
- sqlspec/adapters/sqlite/_typing.py +91 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +1628 -0
- sqlspec/adapters/sqlite/config.py +520 -0
- sqlspec/adapters/sqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/core.py +1035 -0
- sqlspec/adapters/sqlite/data_dictionary.py +327 -0
- sqlspec/adapters/sqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/driver.py +432 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +54 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +367 -0
- sqlspec/adapters/sqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/pool.py +935 -0
- sqlspec/adapters/sqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/adapters/sybase/__init__.py +37 -0
- sqlspec/adapters/sybase/_typing.py +150 -0
- sqlspec/adapters/sybase/adk/__init__.py +5 -0
- sqlspec/adapters/sybase/adk/store.py +1370 -0
- sqlspec/adapters/sybase/config.py +276 -0
- sqlspec/adapters/sybase/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/core.py +578 -0
- sqlspec/adapters/sybase/data_dictionary.py +358 -0
- sqlspec/adapters/sybase/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/driver.py +497 -0
- sqlspec/adapters/sybase/events/__init__.py +5 -0
- sqlspec/adapters/sybase/events/store.py +88 -0
- sqlspec/adapters/sybase/litestar/__init__.py +5 -0
- sqlspec/adapters/sybase/litestar/store.py +328 -0
- sqlspec/adapters/sybase/migrations.py +178 -0
- sqlspec/adapters/sybase/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/pool.py +435 -0
- sqlspec/adapters/teradata/__init__.py +59 -0
- sqlspec/adapters/teradata/_typing.py +145 -0
- sqlspec/adapters/teradata/adk/__init__.py +5 -0
- sqlspec/adapters/teradata/adk/store.py +1300 -0
- sqlspec/adapters/teradata/config.py +324 -0
- sqlspec/adapters/teradata/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/core.py +437 -0
- sqlspec/adapters/teradata/data_dictionary.py +316 -0
- sqlspec/adapters/teradata/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/driver.py +721 -0
- sqlspec/adapters/teradata/events/__init__.py +5 -0
- sqlspec/adapters/teradata/events/store.py +64 -0
- sqlspec/adapters/teradata/litestar/__init__.py +5 -0
- sqlspec/adapters/teradata/litestar/store.py +264 -0
- sqlspec/adapters/teradata/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/migrations.py +80 -0
- sqlspec/adapters/teradata/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/pool.py +377 -0
- sqlspec/adapters/teradata/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/type_converter.py +95 -0
- sqlspec/base.cp315-win_amd64.pyd +0 -0
- sqlspec/base.py +1275 -0
- sqlspec/builder/__init__.py +330 -0
- sqlspec/builder/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_base.py +1752 -0
- sqlspec/builder/_column.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_column.py +508 -0
- sqlspec/builder/_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_ddl.py +4503 -0
- sqlspec/builder/_delete.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_delete.py +75 -0
- sqlspec/builder/_dml.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_dml.py +639 -0
- sqlspec/builder/_explain.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_explain.py +650 -0
- sqlspec/builder/_expression_wrappers.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_expression_wrappers.py +77 -0
- sqlspec/builder/_factory.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_factory.py +1834 -0
- sqlspec/builder/_generation.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_generation.py +55 -0
- sqlspec/builder/_insert.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_insert.py +308 -0
- sqlspec/builder/_join.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_join.py +501 -0
- sqlspec/builder/_locking.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_locking.py +77 -0
- sqlspec/builder/_merge.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_merge.py +1047 -0
- sqlspec/builder/_parsing_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_parsing_utils.py +1197 -0
- sqlspec/builder/_select.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_select.py +1514 -0
- sqlspec/builder/_temporal.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_temporal.py +183 -0
- sqlspec/builder/_update.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_update.py +139 -0
- sqlspec/builder/_values.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_values.py +271 -0
- sqlspec/builder/_vector_distance.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_vector_distance.py +763 -0
- sqlspec/cli.py +1656 -0
- sqlspec/config.py +3402 -0
- sqlspec/core/__init__.py +542 -0
- sqlspec/core/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_cursor.py +564 -0
- sqlspec/core/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_operators.py +167 -0
- sqlspec/core/_ordering.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_ordering.py +151 -0
- sqlspec/core/_pagination.py +66 -0
- sqlspec/core/_pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pipeline.py +343 -0
- sqlspec/core/_pool.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pool.py +72 -0
- sqlspec/core/cache.cp315-win_amd64.pyd +0 -0
- sqlspec/core/cache.py +1503 -0
- sqlspec/core/capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/core/capabilities.py +67 -0
- sqlspec/core/compiler.cp315-win_amd64.pyd +0 -0
- sqlspec/core/compiler.py +1667 -0
- sqlspec/core/config_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/core/config_runtime.py +219 -0
- sqlspec/core/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/core/correlation.py +135 -0
- sqlspec/core/explain.cp315-win_amd64.pyd +0 -0
- sqlspec/core/explain.py +284 -0
- sqlspec/core/filters.cp315-win_amd64.pyd +0 -0
- sqlspec/core/filters.py +1442 -0
- sqlspec/core/hashing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/hashing.py +394 -0
- sqlspec/core/metrics.cp315-win_amd64.pyd +0 -0
- sqlspec/core/metrics.py +86 -0
- sqlspec/core/parameters/__init__.py +174 -0
- sqlspec/core/parameters/_alignment.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_alignment.py +321 -0
- sqlspec/core/parameters/_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_converter.py +956 -0
- sqlspec/core/parameters/_declared.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_declared.py +154 -0
- sqlspec/core/parameters/_processor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_processor.py +1646 -0
- sqlspec/core/parameters/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_registry.py +207 -0
- sqlspec/core/parameters/_transformers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_transformers.py +318 -0
- sqlspec/core/parameters/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_types.py +658 -0
- sqlspec/core/parameters/_validator.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_validator.py +699 -0
- sqlspec/core/query_modifiers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/query_modifiers.py +559 -0
- sqlspec/core/result/__init__.py +67 -0
- sqlspec/core/result/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/result/_base.py +1772 -0
- sqlspec/core/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/routing.py +270 -0
- sqlspec/core/splitter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/splitter.py +1126 -0
- sqlspec/core/sqlcommenter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/sqlcommenter.py +509 -0
- sqlspec/core/stack.cp315-win_amd64.pyd +0 -0
- sqlspec/core/stack.py +167 -0
- sqlspec/core/statement.cp315-win_amd64.pyd +0 -0
- sqlspec/core/statement.py +2253 -0
- sqlspec/core/tenant/__init__.py +64 -0
- sqlspec/core/tenant/base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/tenant/base.py +123 -0
- sqlspec/core/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/type_converter.py +147 -0
- sqlspec/data_dictionary/__init__.py +237 -0
- sqlspec/data_dictionary/_capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_capabilities.py +142 -0
- sqlspec/data_dictionary/_dependencies.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_dependencies.py +602 -0
- sqlspec/data_dictionary/_index_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_index_ddl.py +562 -0
- sqlspec/data_dictionary/_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_loader.py +344 -0
- sqlspec/data_dictionary/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_registry.py +152 -0
- sqlspec/data_dictionary/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_types.py +1852 -0
- sqlspec/data_dictionary/dialects/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/bigquery/__init__.py +15 -0
- sqlspec/data_dictionary/dialects/bigquery/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/bigquery/config.py +128 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/columns.sql +63 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/constraints.sql +37 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/datasets.sql +14 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/ddl.sql +51 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/dependencies.sql +22 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/indexes.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/routines.sql +50 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/system.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/tables.sql +111 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/views.sql +31 -0
- sqlspec/data_dictionary/dialects/cockroachdb/__init__.py +17 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.py +95 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/columns.sql +163 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/comments.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/crdb_internal.sql +11 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/ddl.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/dependencies.sql +20 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/foreign_keys.sql +62 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/indexes.sql +32 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/objects.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/tables.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/views.sql +11 -0
- sqlspec/data_dictionary/dialects/db2/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/db2/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/db2/config.py +172 -0
- sqlspec/data_dictionary/dialects/db2/sql/columns.sql +98 -0
- sqlspec/data_dictionary/dialects/db2/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/db2/sql/foreign_keys.sql +43 -0
- sqlspec/data_dictionary/dialects/db2/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/db2/sql/objects.sql +53 -0
- sqlspec/data_dictionary/dialects/db2/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/db2/sql/tables.sql +77 -0
- sqlspec/data_dictionary/dialects/db2/sql/version.sql +8 -0
- sqlspec/data_dictionary/dialects/db2/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/duckdb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/duckdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/duckdb/config.py +66 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/columns.sql +150 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/constraints.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/databases.sql +11 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/ddl.sql +221 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/dependencies.sql +50 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/extensions.sql +14 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/foreign_keys.sql +46 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/functions.sql +18 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/indexes.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/objects.sql +30 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/sequences.sql +19 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/system.sql +21 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/tables.sql +59 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/types.sql +12 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mariadb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/ddl.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/objects.sql +50 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/privileges.sql +24 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/system.sql +12 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mssql/__init__.py +51 -0
- sqlspec/data_dictionary/dialects/mssql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mssql/config.py +558 -0
- sqlspec/data_dictionary/dialects/mssql/sql/columns.sql +120 -0
- sqlspec/data_dictionary/dialects/mssql/sql/constraints.sql +106 -0
- sqlspec/data_dictionary/dialects/mssql/sql/ddl.sql +89 -0
- sqlspec/data_dictionary/dialects/mssql/sql/dependencies.sql +17 -0
- sqlspec/data_dictionary/dialects/mssql/sql/extended_properties.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/dialects/mssql/sql/indexes.sql +86 -0
- sqlspec/data_dictionary/dialects/mssql/sql/modules.sql +19 -0
- sqlspec/data_dictionary/dialects/mssql/sql/objects.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/permissions.sql +31 -0
- sqlspec/data_dictionary/dialects/mssql/sql/routines.sql +39 -0
- sqlspec/data_dictionary/dialects/mssql/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/mssql/sql/sequences.sql +18 -0
- sqlspec/data_dictionary/dialects/mssql/sql/storage.sql +22 -0
- sqlspec/data_dictionary/dialects/mssql/sql/system.sql +38 -0
- sqlspec/data_dictionary/dialects/mssql/sql/tables.sql +97 -0
- sqlspec/data_dictionary/dialects/mssql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mssql/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mssql/sql/views.sql +18 -0
- sqlspec/data_dictionary/dialects/mysql/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/mysql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mysql/config.py +363 -0
- sqlspec/data_dictionary/dialects/mysql/dictionary.py +650 -0
- sqlspec/data_dictionary/dialects/mysql/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mysql/sql/components.sql +8 -0
- sqlspec/data_dictionary/dialects/mysql/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mysql/sql/ddl.sql +23 -0
- sqlspec/data_dictionary/dialects/mysql/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mysql/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mysql/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mysql/sql/objects.sql +38 -0
- sqlspec/data_dictionary/dialects/mysql/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mysql/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mysql/sql/privileges.sql +26 -0
- sqlspec/data_dictionary/dialects/mysql/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mysql/sql/system.sql +25 -0
- sqlspec/data_dictionary/dialects/mysql/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mysql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/mysql/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/oracle/__init__.py +39 -0
- sqlspec/data_dictionary/dialects/oracle/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/oracle/config.py +266 -0
- sqlspec/data_dictionary/dialects/oracle/sql/arguments.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/columns.sql +103 -0
- sqlspec/data_dictionary/dialects/oracle/sql/comments.sql +22 -0
- sqlspec/data_dictionary/dialects/oracle/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/oracle/sql/ddl.sql +4 -0
- sqlspec/data_dictionary/dialects/oracle/sql/dependencies.sql +16 -0
- sqlspec/data_dictionary/dialects/oracle/sql/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/grants.sql +34 -0
- sqlspec/data_dictionary/dialects/oracle/sql/indexes.sql +87 -0
- sqlspec/data_dictionary/dialects/oracle/sql/lob_storage.sql +28 -0
- sqlspec/data_dictionary/dialects/oracle/sql/materialized_views.sql +27 -0
- sqlspec/data_dictionary/dialects/oracle/sql/objects.sql +26 -0
- sqlspec/data_dictionary/dialects/oracle/sql/partitions.sql +44 -0
- sqlspec/data_dictionary/dialects/oracle/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/sequences.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/source.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/system.sql +37 -0
- sqlspec/data_dictionary/dialects/oracle/sql/tables.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/triggers.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/version.sql +25 -0
- sqlspec/data_dictionary/dialects/oracle/sql/views.sql +49 -0
- sqlspec/data_dictionary/dialects/postgres/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/postgres/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/postgres/config.py +119 -0
- sqlspec/data_dictionary/dialects/postgres/sql/columns.sql +130 -0
- sqlspec/data_dictionary/dialects/postgres/sql/comments.sql +27 -0
- sqlspec/data_dictionary/dialects/postgres/sql/constraints.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/ddl.sql +55 -0
- sqlspec/data_dictionary/dialects/postgres/sql/dependencies.sql +42 -0
- sqlspec/data_dictionary/dialects/postgres/sql/extensions.sql +11 -0
- sqlspec/data_dictionary/dialects/postgres/sql/foreign_keys.sql +72 -0
- sqlspec/data_dictionary/dialects/postgres/sql/indexes.sql +84 -0
- sqlspec/data_dictionary/dialects/postgres/sql/materialized_views.sql +17 -0
- sqlspec/data_dictionary/dialects/postgres/sql/objects.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/partitions.sql +19 -0
- sqlspec/data_dictionary/dialects/postgres/sql/privileges.sql +29 -0
- sqlspec/data_dictionary/dialects/postgres/sql/routines.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/postgres/sql/sequences.sql +32 -0
- sqlspec/data_dictionary/dialects/postgres/sql/system.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/tables.sql +67 -0
- sqlspec/data_dictionary/dialects/postgres/sql/triggers.sql +20 -0
- sqlspec/data_dictionary/dialects/postgres/sql/types.sql +21 -0
- sqlspec/data_dictionary/dialects/postgres/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/postgres/sql/views.sql +17 -0
- sqlspec/data_dictionary/dialects/snowflake/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/snowflake/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/snowflake/config.py +321 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/columns.sql +48 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/constraints.sql +64 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/ddl.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/foreign_keys.sql +7 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/objects.sql +34 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/routines.sql +79 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/schemas.sql +19 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/sequences.sql +45 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/tables.sql +29 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/views.sql +37 -0
- sqlspec/data_dictionary/dialects/spanner/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/spanner/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/spanner/config.py +67 -0
- sqlspec/data_dictionary/dialects/spanner/sql/columns.sql +58 -0
- sqlspec/data_dictionary/dialects/spanner/sql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/columns.sql +46 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/database.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/indexes.sql +66 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/placements.sql +8 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/property_graphs.sql +11 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/routines.sql +33 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/tables.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/views.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/indexes.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/columns.sql +34 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/indexes.sql +52 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/spanner/sql/tables.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.py +191 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/columns.sql +97 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/constraints.sql +43 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/objects.sql +18 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/schemas.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/tables.sql +86 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlite/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/sqlite/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlite/config.py +412 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/columns.sql +59 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/compile_options.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/ddl.sql +37 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/functions.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/indexes.sql +76 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/modules.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/schemas.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/system.sql +7 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/triggers.sql +10 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/views.sql +10 -0
- sqlspec/data_dictionary/dialects/sybase/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sybase/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sybase/config.py +187 -0
- sqlspec/data_dictionary/dialects/sybase/sql/columns.sql +137 -0
- sqlspec/data_dictionary/dialects/sybase/sql/constraints.sql +85 -0
- sqlspec/data_dictionary/dialects/sybase/sql/foreign_keys.sql +81 -0
- sqlspec/data_dictionary/dialects/sybase/sql/indexes.sql +51 -0
- sqlspec/data_dictionary/dialects/sybase/sql/objects.sql +21 -0
- sqlspec/data_dictionary/dialects/sybase/sql/schemas.sql +16 -0
- sqlspec/data_dictionary/dialects/sybase/sql/tables.sql +46 -0
- sqlspec/data_dictionary/dialects/sybase/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sybase/sql/views.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/__init__.py +33 -0
- sqlspec/data_dictionary/dialects/teradata/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/teradata/config.py +228 -0
- sqlspec/data_dictionary/dialects/teradata/sql/columns.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/constraints.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/sql/foreign_keys.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/indexes.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/objects.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/schemas.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/version.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/views.sql +4 -0
- sqlspec/dialects/__init__.py +44 -0
- sqlspec/dialects/db2/__init__.py +111 -0
- sqlspec/dialects/db2/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_generators.py +376 -0
- sqlspec/dialects/db2/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_parsers.py +657 -0
- sqlspec/dialects/db2/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_transforms.py +175 -0
- sqlspec/dialects/postgres/__init__.py +10 -0
- sqlspec/dialects/postgres/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_generators.py +81 -0
- sqlspec/dialects/postgres/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_operators.py +95 -0
- sqlspec/dialects/postgres/_paradedb.py +44 -0
- sqlspec/dialects/postgres/_pg_textsearch.py +38 -0
- sqlspec/dialects/postgres/_pgvector.py +36 -0
- sqlspec/dialects/spanner/__init__.py +69 -0
- sqlspec/dialects/spanner/_expressions.py +247 -0
- sqlspec/dialects/spanner/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_generators.py +961 -0
- sqlspec/dialects/spanner/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_parsers.py +871 -0
- sqlspec/dialects/spanner/_spangres.py +43 -0
- sqlspec/dialects/spanner/_spanner.py +57 -0
- sqlspec/dialects/sybase/__init__.py +115 -0
- sqlspec/dialects/sybase/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_generators.py +379 -0
- sqlspec/dialects/sybase/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_parsers.py +225 -0
- sqlspec/dialects/sybase/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_transforms.py +68 -0
- sqlspec/dialects/teradata/__init__.py +42 -0
- sqlspec/dialects/teradata/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/teradata/_generators.py +203 -0
- sqlspec/driver/__init__.py +151 -0
- sqlspec/driver/_async.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_async.py +3244 -0
- sqlspec/driver/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_common.py +4765 -0
- sqlspec/driver/_deferred.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_deferred.py +232 -0
- sqlspec/driver/_exception_handler.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_exception_handler.py +224 -0
- sqlspec/driver/_routing.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_routing.py +2891 -0
- sqlspec/driver/_session.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_session.py +180 -0
- sqlspec/driver/_sql_helpers.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sql_helpers.py +140 -0
- sqlspec/driver/_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_stream.py +392 -0
- sqlspec/driver/_sync.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sync.py +3107 -0
- sqlspec/driver/_tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_tenant.py +326 -0
- sqlspec/exceptions.cp315-win_amd64.pyd +0 -0
- sqlspec/exceptions.py +568 -0
- sqlspec/extensions/__init__.py +3 -0
- sqlspec/extensions/adk/__init__.py +136 -0
- sqlspec/extensions/adk/_config_utils.py +306 -0
- sqlspec/extensions/adk/_table_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_table_utils.py +126 -0
- sqlspec/extensions/adk/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_types.py +59 -0
- sqlspec/extensions/adk/artifact/__init__.py +18 -0
- sqlspec/extensions/adk/artifact/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/artifact/_types.py +41 -0
- sqlspec/extensions/adk/artifact/service.py +657 -0
- sqlspec/extensions/adk/artifact/store.py +444 -0
- sqlspec/extensions/adk/converters.py +230 -0
- sqlspec/extensions/adk/maintenance.py +262 -0
- sqlspec/extensions/adk/memory/__init__.py +36 -0
- sqlspec/extensions/adk/memory/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/memory/_types.py +48 -0
- sqlspec/extensions/adk/memory/converters.py +271 -0
- sqlspec/extensions/adk/memory/service.py +474 -0
- sqlspec/extensions/adk/memory/store.py +586 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +181 -0
- sqlspec/extensions/adk/migrations/0002_create_mssql_python_memory.py +51 -0
- sqlspec/extensions/adk/migrations/__init__.py +3 -0
- sqlspec/extensions/adk/migrations/reconcile.py +282 -0
- sqlspec/extensions/adk/service.py +463 -0
- sqlspec/extensions/adk/store.py +1239 -0
- sqlspec/extensions/events/__init__.py +132 -0
- sqlspec/extensions/events/_buffer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_buffer.py +38 -0
- sqlspec/extensions/events/_channel.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_channel.py +1144 -0
- sqlspec/extensions/events/_hints.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_hints.py +38 -0
- sqlspec/extensions/events/_models.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_models.py +22 -0
- sqlspec/extensions/events/_names.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_names.py +27 -0
- sqlspec/extensions/events/_payload.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_payload.py +139 -0
- sqlspec/extensions/events/_protocols.py +154 -0
- sqlspec/extensions/events/_queue.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_queue.py +1147 -0
- sqlspec/extensions/events/_store.py +318 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +106 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/events/migrations/reconcile.py +145 -0
- sqlspec/extensions/events/primitives.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/primitives.py +91 -0
- sqlspec/extensions/fastapi/__init__.py +26 -0
- sqlspec/extensions/fastapi/extension.py +360 -0
- sqlspec/extensions/fastapi/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/fastapi/providers.py +1091 -0
- sqlspec/extensions/flask/__init__.py +20 -0
- sqlspec/extensions/flask/_portal.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_portal.py +212 -0
- sqlspec/extensions/flask/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_state.py +135 -0
- sqlspec/extensions/flask/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_utils.py +171 -0
- sqlspec/extensions/flask/extension.py +1234 -0
- sqlspec/extensions/litestar/__init__.py +52 -0
- sqlspec/extensions/litestar/_tenant_resolution.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_tenant_resolution.py +314 -0
- sqlspec/extensions/litestar/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_utils.py +222 -0
- sqlspec/extensions/litestar/channels.py +249 -0
- sqlspec/extensions/litestar/cli.py +100 -0
- sqlspec/extensions/litestar/config.py +5 -0
- sqlspec/extensions/litestar/handlers.py +796 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +138 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/migrations/reconcile.py +132 -0
- sqlspec/extensions/litestar/plugin.py +2172 -0
- sqlspec/extensions/litestar/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/providers.py +1239 -0
- sqlspec/extensions/litestar/store.py +613 -0
- sqlspec/extensions/litestar/tenant.py +292 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +5 -0
- sqlspec/extensions/prometheus/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/prometheus/_observer.py +152 -0
- sqlspec/extensions/sanic/__init__.py +28 -0
- sqlspec/extensions/sanic/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_state.py +102 -0
- sqlspec/extensions/sanic/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_utils.py +234 -0
- sqlspec/extensions/sanic/extension.py +1467 -0
- sqlspec/extensions/starlette/__init__.py +31 -0
- sqlspec/extensions/starlette/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_state.py +103 -0
- sqlspec/extensions/starlette/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_utils.py +267 -0
- sqlspec/extensions/starlette/extension.py +691 -0
- sqlspec/extensions/starlette/middleware.py +845 -0
- sqlspec/loader.cp315-win_amd64.pyd +0 -0
- sqlspec/loader.py +1733 -0
- sqlspec/migrations/__init__.py +104 -0
- sqlspec/migrations/_backup.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/_backup.py +36 -0
- sqlspec/migrations/base.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/base.py +1688 -0
- sqlspec/migrations/commands.py +4002 -0
- sqlspec/migrations/context.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/context.py +158 -0
- sqlspec/migrations/fix.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/fix.py +193 -0
- sqlspec/migrations/loaders.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/loaders.py +835 -0
- sqlspec/migrations/runner.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/runner.py +2144 -0
- sqlspec/migrations/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/schema.py +1266 -0
- sqlspec/migrations/squash.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/squash.py +2452 -0
- sqlspec/migrations/templates.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/templates.py +310 -0
- sqlspec/migrations/tracker.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/tracker.py +1529 -0
- sqlspec/migrations/utils.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/utils.py +534 -0
- sqlspec/migrations/validation.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/validation.py +355 -0
- sqlspec/migrations/version.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/version.py +455 -0
- sqlspec/observability/__init__.py +122 -0
- sqlspec/observability/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_common.py +307 -0
- sqlspec/observability/_config.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_config.py +362 -0
- sqlspec/observability/_diagnostics.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_diagnostics.py +75 -0
- sqlspec/observability/_dispatcher.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_dispatcher.py +320 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_aws.py +90 -0
- sqlspec/observability/_formatters/_azure.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_azure.py +84 -0
- sqlspec/observability/_formatters/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_base.py +40 -0
- sqlspec/observability/_formatters/_gcp.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_gcp.py +119 -0
- sqlspec/observability/_formatting.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatting.py +76 -0
- sqlspec/observability/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_observer.py +445 -0
- sqlspec/observability/_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_runtime.py +740 -0
- sqlspec/observability/_sampling.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_sampling.py +169 -0
- sqlspec/observability/_spans.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_spans.py +212 -0
- sqlspec/protocols.py +1235 -0
- sqlspec/py.typed +0 -0
- sqlspec/service/__init__.py +5 -0
- sqlspec/service/_base.py +1051 -0
- sqlspec/service/_core.cp315-win_amd64.pyd +0 -0
- sqlspec/service/_core.py +625 -0
- sqlspec/storage/__init__.py +111 -0
- sqlspec/storage/_arrow_payload.py +802 -0
- sqlspec/storage/_arrow_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_arrow_stream.py +134 -0
- sqlspec/storage/_ingest.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_ingest.py +810 -0
- sqlspec/storage/_paths.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_paths.py +313 -0
- sqlspec/storage/_staging_sql.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_staging_sql.py +695 -0
- sqlspec/storage/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_utils.py +174 -0
- sqlspec/storage/backends/__init__.py +43 -0
- sqlspec/storage/backends/base.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/base.py +399 -0
- sqlspec/storage/backends/fsspec.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/fsspec.py +1390 -0
- sqlspec/storage/backends/local.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/local.py +968 -0
- sqlspec/storage/backends/obstore.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/obstore.py +1974 -0
- sqlspec/storage/errors.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/errors.py +127 -0
- sqlspec/storage/pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/pipeline.py +1270 -0
- sqlspec/storage/registry.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/registry.py +318 -0
- sqlspec/typing.py +261 -0
- sqlspec/utils/__init__.py +9 -0
- sqlspec/utils/adapters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/adapters.py +186 -0
- sqlspec/utils/arrow_helpers.py +2157 -0
- sqlspec/utils/config_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/config_tools.py +712 -0
- sqlspec/utils/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/correlation.py +137 -0
- sqlspec/utils/deprecation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/deprecation.py +222 -0
- sqlspec/utils/dispatch.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/dispatch.py +104 -0
- sqlspec/utils/env.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/env.py +437 -0
- sqlspec/utils/fixtures.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/fixtures.py +2470 -0
- sqlspec/utils/logging.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/logging.py +267 -0
- sqlspec/utils/module_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/module_loader.py +399 -0
- sqlspec/utils/portal.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/portal.py +411 -0
- sqlspec/utils/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/routing.py +645 -0
- sqlspec/utils/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/schema.py +1050 -0
- sqlspec/utils/serializers/__init__.py +69 -0
- sqlspec/utils/serializers/_json.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_json.py +525 -0
- sqlspec/utils/serializers/_numpy.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_numpy.py +65 -0
- sqlspec/utils/serializers/_schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_schema.py +340 -0
- sqlspec/utils/sync_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/sync_tools.py +502 -0
- sqlspec/utils/tenant/__init__.py +71 -0
- sqlspec/utils/tenant/_context.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_context.py +550 -0
- sqlspec/utils/tenant/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_cursor.py +43 -0
- sqlspec/utils/tenant/_mssql.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_mssql.py +189 -0
- sqlspec/utils/tenant/_postgres.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_postgres.py +142 -0
- sqlspec/utils/text.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/text.py +317 -0
- sqlspec/utils/type_converters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_converters.py +220 -0
- sqlspec/utils/type_guards.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_guards.py +1505 -0
- sqlspec/utils/uuids.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/uuids.py +263 -0
- sqlspec-0.72.0.dist-info/METADATA +228 -0
- sqlspec-0.72.0.dist-info/RECORD +1144 -0
- sqlspec-0.72.0.dist-info/WHEEL +4 -0
- sqlspec-0.72.0.dist-info/entry_points.txt +13 -0
- sqlspec-0.72.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1323 @@
|
|
|
1
|
+
"""Multi-connection pool for aiosqlite."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
import time
|
|
6
|
+
from contextlib import suppress
|
|
7
|
+
from inspect import isawaitable
|
|
8
|
+
from threading import Thread
|
|
9
|
+
from typing import TYPE_CHECKING, Any, Final, cast
|
|
10
|
+
from urllib.parse import parse_qs, unquote, urlsplit
|
|
11
|
+
|
|
12
|
+
from mypy_extensions import mypyc_attr
|
|
13
|
+
|
|
14
|
+
from sqlspec.adapters.aiosqlite._typing import aiosqlite_module as aiosqlite
|
|
15
|
+
from sqlspec.adapters.aiosqlite._typing import aiosqlite_sqlite_module as sqlite3
|
|
16
|
+
from sqlspec.adapters.aiosqlite.core import (
|
|
17
|
+
create_mapped_exception,
|
|
18
|
+
end_transaction,
|
|
19
|
+
is_read_only_sqlite_config,
|
|
20
|
+
run_on_worker_thread,
|
|
21
|
+
)
|
|
22
|
+
from sqlspec.exceptions import ConnectionTimeoutError, ImproperConfigurationError, SQLSpecError, with_cause
|
|
23
|
+
from sqlspec.utils.logging import POOL_LOGGER_NAME, get_logger, log_with_context
|
|
24
|
+
from sqlspec.utils.sync_tools import exit_async_context
|
|
25
|
+
from sqlspec.utils.uuids import uuid4
|
|
26
|
+
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
from collections.abc import Awaitable, Callable, Mapping, Sequence
|
|
29
|
+
from types import TracebackType
|
|
30
|
+
|
|
31
|
+
from sqlspec.adapters.aiosqlite._typing import AiosqliteConnection
|
|
32
|
+
|
|
33
|
+
__all__ = (
|
|
34
|
+
"AiosqliteConnectTimeoutError",
|
|
35
|
+
"AiosqliteConnectionPool",
|
|
36
|
+
"AiosqlitePoolClosedError",
|
|
37
|
+
"AiosqlitePoolConnection",
|
|
38
|
+
"AiosqlitePoolConnectionContext",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
logger = get_logger(POOL_LOGGER_NAME)
|
|
42
|
+
|
|
43
|
+
_ADAPTER_NAME = "aiosqlite"
|
|
44
|
+
SQLITE_BUSY_TIMEOUT: Final = 5000
|
|
45
|
+
SQLITE_DEFAULT_ENABLE_FOREIGN_KEYS: Final = False
|
|
46
|
+
SQLITE_DEFAULT_ENABLE_OPTIMIZATIONS: Final = True
|
|
47
|
+
SQLITE_MEMORY_CACHE_SIZE: Final = -16000
|
|
48
|
+
SQLITE_WAL_SWITCH_ATTEMPTS: Final = 50
|
|
49
|
+
SQLITE_WAL_SWITCH_DELAY: Final = 0.01
|
|
50
|
+
_SESSION_BASELINE_PRAGMAS: Final[tuple[tuple[str, str], ...]] = (
|
|
51
|
+
("foreign_keys", "OFF"),
|
|
52
|
+
("query_only", "OFF"),
|
|
53
|
+
("trusted_schema", "ON"),
|
|
54
|
+
("cell_size_check", "OFF"),
|
|
55
|
+
("recursive_triggers", "OFF"),
|
|
56
|
+
)
|
|
57
|
+
_TEMP_OBJECT_DROP_ORDER: Final[tuple[str, ...]] = ("trigger", "view", "index", "table")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class AiosqlitePoolClosedError(SQLSpecError):
|
|
61
|
+
"""Pool has been closed and cannot accept new operations."""
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class AiosqliteConnectTimeoutError(ConnectionTimeoutError):
|
|
65
|
+
"""Connection could not be established within the specified timeout period."""
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
69
|
+
class AiosqlitePoolConnection:
|
|
70
|
+
"""Wrapper for database connections in the pool."""
|
|
71
|
+
|
|
72
|
+
__slots__ = ("_closed", "_healthy", "connection", "id", "idle_since")
|
|
73
|
+
|
|
74
|
+
def __init__(self, connection: "AiosqliteConnection") -> None:
|
|
75
|
+
"""Initialize pool connection wrapper.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
connection: The raw aiosqlite connection
|
|
79
|
+
"""
|
|
80
|
+
self.id = uuid4().hex
|
|
81
|
+
self.connection = connection
|
|
82
|
+
self.idle_since: float | None = None
|
|
83
|
+
self._closed = False
|
|
84
|
+
self._healthy = True
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def idle_time(self) -> float:
|
|
88
|
+
"""Get idle time in seconds.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
Idle time in seconds, 0.0 if connection is in use
|
|
92
|
+
"""
|
|
93
|
+
if self.idle_since is None:
|
|
94
|
+
return 0.0
|
|
95
|
+
return time.time() - self.idle_since
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def is_closed(self) -> bool:
|
|
99
|
+
"""Check if connection is closed.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
True if connection is closed
|
|
103
|
+
"""
|
|
104
|
+
return self._closed
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def is_healthy(self) -> bool:
|
|
108
|
+
"""Check if connection was healthy on last check.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
True if connection is presumed healthy
|
|
112
|
+
"""
|
|
113
|
+
return self._healthy and not self._closed
|
|
114
|
+
|
|
115
|
+
def mark_as_in_use(self) -> None:
|
|
116
|
+
"""Mark connection as in use."""
|
|
117
|
+
self.idle_since = None
|
|
118
|
+
|
|
119
|
+
def mark_as_idle(self) -> None:
|
|
120
|
+
"""Mark connection as idle."""
|
|
121
|
+
self.idle_since = time.time()
|
|
122
|
+
|
|
123
|
+
def mark_unhealthy(self) -> None:
|
|
124
|
+
"""Mark connection as unhealthy."""
|
|
125
|
+
self._healthy = False
|
|
126
|
+
|
|
127
|
+
async def is_alive(self) -> bool:
|
|
128
|
+
"""Check if connection is alive and functional.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
True if connection is healthy
|
|
132
|
+
"""
|
|
133
|
+
if self._closed:
|
|
134
|
+
self._healthy = False
|
|
135
|
+
return False
|
|
136
|
+
try:
|
|
137
|
+
cursor = await self.connection.execute("SELECT 1")
|
|
138
|
+
if cursor is not None and callable(getattr(cursor, "close", None)):
|
|
139
|
+
with suppress(Exception):
|
|
140
|
+
await cursor.close()
|
|
141
|
+
except Exception:
|
|
142
|
+
self._healthy = False
|
|
143
|
+
return False
|
|
144
|
+
else:
|
|
145
|
+
self._healthy = True
|
|
146
|
+
return True
|
|
147
|
+
|
|
148
|
+
async def reset(self) -> None:
|
|
149
|
+
"""Reset connection to clean state."""
|
|
150
|
+
if self._closed:
|
|
151
|
+
return
|
|
152
|
+
with suppress(Exception):
|
|
153
|
+
await end_transaction(self.connection, commit=False)
|
|
154
|
+
|
|
155
|
+
async def close(self) -> None:
|
|
156
|
+
"""Close the connection."""
|
|
157
|
+
if self._closed:
|
|
158
|
+
return
|
|
159
|
+
try:
|
|
160
|
+
with suppress(Exception):
|
|
161
|
+
await end_transaction(self.connection, commit=False)
|
|
162
|
+
await self.connection.close()
|
|
163
|
+
except Exception:
|
|
164
|
+
log_with_context(
|
|
165
|
+
logger, logging.DEBUG, "pool.connection.close.error", adapter=_ADAPTER_NAME, connection_id=self.id
|
|
166
|
+
)
|
|
167
|
+
finally:
|
|
168
|
+
self._closed = True
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
172
|
+
class AiosqlitePoolConnectionContext:
|
|
173
|
+
"""Async context manager for pooled aiosqlite connections."""
|
|
174
|
+
|
|
175
|
+
__slots__ = ("_connection", "_pool")
|
|
176
|
+
|
|
177
|
+
def __init__(self, pool: "AiosqliteConnectionPool") -> None:
|
|
178
|
+
"""Initialize the context manager.
|
|
179
|
+
|
|
180
|
+
Args:
|
|
181
|
+
pool: Connection pool instance.
|
|
182
|
+
"""
|
|
183
|
+
self._pool = pool
|
|
184
|
+
self._connection: AiosqlitePoolConnection | None = None
|
|
185
|
+
|
|
186
|
+
async def __aenter__(self) -> "AiosqliteConnection":
|
|
187
|
+
self._connection = await self._pool.acquire()
|
|
188
|
+
return self._connection.connection
|
|
189
|
+
|
|
190
|
+
async def __aexit__(
|
|
191
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
192
|
+
) -> "bool | None":
|
|
193
|
+
connection = self._connection
|
|
194
|
+
if connection is None:
|
|
195
|
+
return False
|
|
196
|
+
self._connection = None
|
|
197
|
+
raw_connection = connection.connection
|
|
198
|
+
commit_error: BaseException | None = None
|
|
199
|
+
if exc_type is None and not connection.is_closed:
|
|
200
|
+
try:
|
|
201
|
+
await end_transaction(raw_connection, commit=True)
|
|
202
|
+
except BaseException as exc:
|
|
203
|
+
commit_error = exc
|
|
204
|
+
else:
|
|
205
|
+
await self._pool._release_checked(connection)
|
|
206
|
+
return False
|
|
207
|
+
if commit_error is not None:
|
|
208
|
+
try:
|
|
209
|
+
await end_transaction(raw_connection, commit=False)
|
|
210
|
+
except BaseException:
|
|
211
|
+
connection.mark_unhealthy()
|
|
212
|
+
await self._pool._release_checked(connection)
|
|
213
|
+
raise commit_error
|
|
214
|
+
await self._pool.release(connection)
|
|
215
|
+
return False
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
219
|
+
class AiosqliteConnectionPool:
|
|
220
|
+
"""Multi-connection pool for aiosqlite."""
|
|
221
|
+
|
|
222
|
+
__slots__ = (
|
|
223
|
+
"_abandoned_workers",
|
|
224
|
+
"_anchor_connection",
|
|
225
|
+
"_closed_event",
|
|
226
|
+
"_connect_timeout",
|
|
227
|
+
"_connection_parameters",
|
|
228
|
+
"_connection_registry",
|
|
229
|
+
"_enable_foreign_keys",
|
|
230
|
+
"_enable_optimizations",
|
|
231
|
+
"_health_check_interval",
|
|
232
|
+
"_idle_timeout",
|
|
233
|
+
"_in_flight_creations",
|
|
234
|
+
"_is_read_only",
|
|
235
|
+
"_lock",
|
|
236
|
+
"_min_size",
|
|
237
|
+
"_on_connection_create",
|
|
238
|
+
"_operation_timeout",
|
|
239
|
+
"_pool_id",
|
|
240
|
+
"_pool_size",
|
|
241
|
+
"_queue",
|
|
242
|
+
"_reset_session_on_release",
|
|
243
|
+
"_runtime_setup",
|
|
244
|
+
"_warmed",
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
def __init__(
|
|
248
|
+
self,
|
|
249
|
+
connection_parameters: "dict[str, Any]",
|
|
250
|
+
pool_size: int = 5,
|
|
251
|
+
min_size: int = 0,
|
|
252
|
+
connect_timeout: float = 30.0,
|
|
253
|
+
idle_timeout: float = 24 * 60 * 60,
|
|
254
|
+
operation_timeout: float = 10.0,
|
|
255
|
+
health_check_interval: float = 30.0,
|
|
256
|
+
enable_optimizations: bool = SQLITE_DEFAULT_ENABLE_OPTIMIZATIONS,
|
|
257
|
+
enable_foreign_keys: bool = SQLITE_DEFAULT_ENABLE_FOREIGN_KEYS,
|
|
258
|
+
on_connection_create: "Callable[[AiosqliteConnection], Awaitable[None]] | None" = None,
|
|
259
|
+
runtime_setup: "dict[str, Any] | None" = None,
|
|
260
|
+
is_read_only: bool = False,
|
|
261
|
+
reset_session_on_release: bool = False,
|
|
262
|
+
) -> None:
|
|
263
|
+
"""Initialize connection pool.
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
connection_parameters: SQLite connection parameters
|
|
267
|
+
pool_size: Maximum number of connections in the pool
|
|
268
|
+
min_size: Minimum connections to pre-create (pool warming)
|
|
269
|
+
connect_timeout: Maximum time to wait for connection acquisition
|
|
270
|
+
idle_timeout: Maximum time a connection can remain idle
|
|
271
|
+
operation_timeout: Maximum time for connection operations
|
|
272
|
+
health_check_interval: Seconds of idle time before running health check
|
|
273
|
+
enable_optimizations: Whether to apply performance PRAGMAs
|
|
274
|
+
enable_foreign_keys: Whether to enable foreign-key enforcement
|
|
275
|
+
on_connection_create: Async callback executed when connection is created
|
|
276
|
+
runtime_setup: Runtime feature setup to apply to new connections
|
|
277
|
+
is_read_only: Enforce read-only queries and omit write PRAGMAs.
|
|
278
|
+
reset_session_on_release: Drop temp objects, detach databases, and restore baseline PRAGMAs when a
|
|
279
|
+
connection is released.
|
|
280
|
+
"""
|
|
281
|
+
self._is_read_only = is_read_only or is_read_only_sqlite_config(connection_parameters)
|
|
282
|
+
self._connection_parameters = connection_parameters
|
|
283
|
+
self._pool_size = pool_size
|
|
284
|
+
self._min_size = min(min_size, pool_size)
|
|
285
|
+
self._connect_timeout = connect_timeout
|
|
286
|
+
self._idle_timeout = idle_timeout
|
|
287
|
+
self._operation_timeout = operation_timeout
|
|
288
|
+
self._health_check_interval = health_check_interval
|
|
289
|
+
self._enable_optimizations = enable_optimizations
|
|
290
|
+
self._enable_foreign_keys = enable_foreign_keys
|
|
291
|
+
self._on_connection_create = on_connection_create
|
|
292
|
+
self._runtime_setup = runtime_setup
|
|
293
|
+
self._reset_session_on_release = reset_session_on_release
|
|
294
|
+
|
|
295
|
+
self._anchor_connection: sqlite3.Connection | None = None
|
|
296
|
+
self._abandoned_workers: set[Thread] = set()
|
|
297
|
+
self._connection_registry: dict[str, AiosqlitePoolConnection] = {}
|
|
298
|
+
self._in_flight_creations = 0
|
|
299
|
+
self._warmed = False
|
|
300
|
+
self._pool_id = uuid4().hex[:8]
|
|
301
|
+
|
|
302
|
+
self._queue: asyncio.Queue[AiosqlitePoolConnection] = asyncio.Queue(maxsize=self._pool_size)
|
|
303
|
+
self._lock: asyncio.Lock = asyncio.Lock()
|
|
304
|
+
self._closed_event: asyncio.Event = asyncio.Event()
|
|
305
|
+
|
|
306
|
+
@property
|
|
307
|
+
def is_closed(self) -> bool:
|
|
308
|
+
"""Check if pool is closed.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
True if pool is closed
|
|
312
|
+
"""
|
|
313
|
+
return self._closed_event.is_set()
|
|
314
|
+
|
|
315
|
+
@property
|
|
316
|
+
def _database_name(self) -> str:
|
|
317
|
+
"""Get sanitized database name for logging."""
|
|
318
|
+
db = self._connection_parameters.get("database", "unknown")
|
|
319
|
+
return str(db).split("/")[-1] if db else "unknown"
|
|
320
|
+
|
|
321
|
+
def size(self) -> int:
|
|
322
|
+
"""Get total number of connections in pool.
|
|
323
|
+
|
|
324
|
+
Returns:
|
|
325
|
+
Total connection count
|
|
326
|
+
"""
|
|
327
|
+
return len(self._connection_registry)
|
|
328
|
+
|
|
329
|
+
def checked_out(self) -> int:
|
|
330
|
+
"""Get number of checked out connections.
|
|
331
|
+
|
|
332
|
+
Returns:
|
|
333
|
+
Number of connections currently in use
|
|
334
|
+
"""
|
|
335
|
+
return len(self._connection_registry) - self._queue.qsize()
|
|
336
|
+
|
|
337
|
+
async def new_connection(self) -> "AiosqliteConnection":
|
|
338
|
+
"""Open a standalone connection configured exactly like a pooled one.
|
|
339
|
+
|
|
340
|
+
The result is owned by the caller: the pool neither tracks nor closes it.
|
|
341
|
+
|
|
342
|
+
Returns:
|
|
343
|
+
A newly opened, fully configured connection.
|
|
344
|
+
"""
|
|
345
|
+
connect_proxy = aiosqlite.connect(**self._connection_parameters)
|
|
346
|
+
self._set_connect_proxy_daemon(connect_proxy)
|
|
347
|
+
try:
|
|
348
|
+
connection = await connect_proxy
|
|
349
|
+
except BaseException as exc:
|
|
350
|
+
self._detach_worker(connect_proxy)
|
|
351
|
+
if isinstance(exc, sqlite3.Error) and getattr(exc, "sqlite_errorcode", 0) & 0xFF in (
|
|
352
|
+
sqlite3.SQLITE_CANTOPEN,
|
|
353
|
+
26,
|
|
354
|
+
):
|
|
355
|
+
raise with_cause(create_mapped_exception(exc), exc) from exc
|
|
356
|
+
raise
|
|
357
|
+
|
|
358
|
+
pragma_lines: list[str] = []
|
|
359
|
+
setup_error: BaseException | None = None
|
|
360
|
+
|
|
361
|
+
try:
|
|
362
|
+
is_memory_db, is_shared_cache = _classify_memory_mode(self._connection_parameters)
|
|
363
|
+
configure_failed = False
|
|
364
|
+
try:
|
|
365
|
+
if self._enable_optimizations:
|
|
366
|
+
if is_memory_db:
|
|
367
|
+
pragma_lines.extend([
|
|
368
|
+
"PRAGMA journal_mode = MEMORY",
|
|
369
|
+
"PRAGMA synchronous = OFF",
|
|
370
|
+
"PRAGMA temp_store = MEMORY",
|
|
371
|
+
f"PRAGMA cache_size = {SQLITE_MEMORY_CACHE_SIZE}",
|
|
372
|
+
])
|
|
373
|
+
elif not self._is_read_only:
|
|
374
|
+
await _enable_wal(connection)
|
|
375
|
+
pragma_lines.append("PRAGMA synchronous = NORMAL")
|
|
376
|
+
|
|
377
|
+
pragma_lines.append(f"PRAGMA busy_timeout = {SQLITE_BUSY_TIMEOUT}")
|
|
378
|
+
if is_shared_cache and is_memory_db:
|
|
379
|
+
pragma_lines.append("PRAGMA read_uncommitted = ON")
|
|
380
|
+
|
|
381
|
+
if self._is_read_only:
|
|
382
|
+
pragma_lines.append("PRAGMA query_only = ON")
|
|
383
|
+
|
|
384
|
+
if self._enable_foreign_keys:
|
|
385
|
+
pragma_lines.append("PRAGMA foreign_keys = ON")
|
|
386
|
+
|
|
387
|
+
if pragma_lines:
|
|
388
|
+
await connection.executescript(";\n".join(pragma_lines) + ";")
|
|
389
|
+
await connection.commit()
|
|
390
|
+
|
|
391
|
+
except sqlite3.OperationalError:
|
|
392
|
+
raise
|
|
393
|
+
except Exception:
|
|
394
|
+
configure_failed = True
|
|
395
|
+
if configure_failed:
|
|
396
|
+
log_with_context(
|
|
397
|
+
logger,
|
|
398
|
+
logging.WARNING,
|
|
399
|
+
"pool.connection.configure.error",
|
|
400
|
+
adapter=_ADAPTER_NAME,
|
|
401
|
+
pool_id=self._pool_id,
|
|
402
|
+
database=self._database_name,
|
|
403
|
+
)
|
|
404
|
+
for pragma_statement in pragma_lines:
|
|
405
|
+
if pragma_statement == "PRAGMA foreign_keys = ON":
|
|
406
|
+
continue
|
|
407
|
+
with suppress(Exception):
|
|
408
|
+
cursor = await connection.execute(pragma_statement)
|
|
409
|
+
if cursor is not None and callable(getattr(cursor, "close", None)):
|
|
410
|
+
await cursor.close()
|
|
411
|
+
if self._enable_foreign_keys:
|
|
412
|
+
cursor = await connection.execute("PRAGMA foreign_keys = ON")
|
|
413
|
+
if cursor is not None and callable(getattr(cursor, "close", None)):
|
|
414
|
+
with suppress(Exception):
|
|
415
|
+
await cursor.close()
|
|
416
|
+
await connection.commit()
|
|
417
|
+
|
|
418
|
+
if self._runtime_setup is not None:
|
|
419
|
+
await _apply_runtime_setup(connection, self._runtime_setup)
|
|
420
|
+
|
|
421
|
+
if self._on_connection_create is not None:
|
|
422
|
+
await self._on_connection_create(connection)
|
|
423
|
+
except BaseException as exc:
|
|
424
|
+
setup_error = exc
|
|
425
|
+
if setup_error is not None:
|
|
426
|
+
await self._discard_connection(connection)
|
|
427
|
+
raise setup_error
|
|
428
|
+
|
|
429
|
+
return connection
|
|
430
|
+
|
|
431
|
+
async def acquire(self) -> AiosqlitePoolConnection:
|
|
432
|
+
"""Acquire a connection from the pool.
|
|
433
|
+
|
|
434
|
+
Returns:
|
|
435
|
+
Available connection
|
|
436
|
+
|
|
437
|
+
Raises:
|
|
438
|
+
AiosqliteConnectTimeoutError: If acquisition times out
|
|
439
|
+
"""
|
|
440
|
+
fast_connection = self._try_acquire_idle_connection()
|
|
441
|
+
if fast_connection is not None:
|
|
442
|
+
return fast_connection
|
|
443
|
+
try:
|
|
444
|
+
connection = await asyncio.wait_for(self._get_connection(), timeout=self._connect_timeout)
|
|
445
|
+
except AiosqlitePoolClosedError:
|
|
446
|
+
raise
|
|
447
|
+
except TimeoutError as e:
|
|
448
|
+
msg = f"Connection acquisition timed out after {self._connect_timeout}s"
|
|
449
|
+
error = AiosqliteConnectTimeoutError(msg)
|
|
450
|
+
error.__cause__ = e
|
|
451
|
+
raise error from e
|
|
452
|
+
|
|
453
|
+
return connection
|
|
454
|
+
|
|
455
|
+
async def release(self, connection: AiosqlitePoolConnection) -> None:
|
|
456
|
+
"""Release a connection back to the pool.
|
|
457
|
+
|
|
458
|
+
Args:
|
|
459
|
+
connection: Connection to release
|
|
460
|
+
"""
|
|
461
|
+
if self._closed_event.is_set():
|
|
462
|
+
await self._retire_connection(connection)
|
|
463
|
+
return
|
|
464
|
+
|
|
465
|
+
if connection.id not in self._connection_registry:
|
|
466
|
+
log_with_context(
|
|
467
|
+
logger,
|
|
468
|
+
logging.WARNING,
|
|
469
|
+
"pool.connection.release.unknown",
|
|
470
|
+
adapter=_ADAPTER_NAME,
|
|
471
|
+
pool_id=self._pool_id,
|
|
472
|
+
connection_id=connection.id,
|
|
473
|
+
)
|
|
474
|
+
return
|
|
475
|
+
|
|
476
|
+
raw_conn = connection.connection
|
|
477
|
+
if not connection.is_healthy or connection.is_closed or getattr(raw_conn, "_connection", True) is None:
|
|
478
|
+
connection.mark_unhealthy()
|
|
479
|
+
await self._retire_connection(connection, reason="unhealthy")
|
|
480
|
+
return
|
|
481
|
+
|
|
482
|
+
reset_error: BaseException | None = None
|
|
483
|
+
try:
|
|
484
|
+
await end_transaction(raw_conn, commit=False)
|
|
485
|
+
if self._reset_session_on_release:
|
|
486
|
+
await self._reset_connection(raw_conn)
|
|
487
|
+
connection.idle_since = time.time()
|
|
488
|
+
self._queue.put_nowait(connection)
|
|
489
|
+
except BaseException as e:
|
|
490
|
+
reset_error = e
|
|
491
|
+
if reset_error is None:
|
|
492
|
+
return
|
|
493
|
+
if isinstance(reset_error, Exception):
|
|
494
|
+
log_with_context(
|
|
495
|
+
logger,
|
|
496
|
+
logging.WARNING,
|
|
497
|
+
"pool.connection.reset.error",
|
|
498
|
+
adapter=_ADAPTER_NAME,
|
|
499
|
+
pool_id=self._pool_id,
|
|
500
|
+
connection_id=connection.id,
|
|
501
|
+
error=str(reset_error),
|
|
502
|
+
)
|
|
503
|
+
connection.mark_unhealthy()
|
|
504
|
+
await self._retire_connection(connection)
|
|
505
|
+
return
|
|
506
|
+
connection.mark_unhealthy()
|
|
507
|
+
await self._retire_connection(connection)
|
|
508
|
+
raise reset_error
|
|
509
|
+
|
|
510
|
+
def get_connection(self) -> "AiosqlitePoolConnectionContext":
|
|
511
|
+
"""Get a connection with automatic release."""
|
|
512
|
+
return AiosqlitePoolConnectionContext(self)
|
|
513
|
+
|
|
514
|
+
async def close(self) -> None:
|
|
515
|
+
"""Close the connection pool and join the worker threads it tracks.
|
|
516
|
+
|
|
517
|
+
Registered connections are closed concurrently, each close bounded by the operation
|
|
518
|
+
timeout; a close that times out force-stops its worker. The worker threads of those
|
|
519
|
+
connections and of connections whose creation or retirement was interrupted are then
|
|
520
|
+
joined under one shared operation timeout. A worker still alive when that timeout
|
|
521
|
+
elapses is logged and left running. A connection whose creation is still in progress
|
|
522
|
+
is discarded by its creator, which joins its worker and raises
|
|
523
|
+
``AiosqlitePoolClosedError``.
|
|
524
|
+
"""
|
|
525
|
+
if self.is_closed:
|
|
526
|
+
return
|
|
527
|
+
self._closed_event.set()
|
|
528
|
+
|
|
529
|
+
while not self._queue.empty():
|
|
530
|
+
self._queue.get_nowait()
|
|
531
|
+
|
|
532
|
+
async with self._lock:
|
|
533
|
+
connections = list(self._connection_registry.values())
|
|
534
|
+
self._connection_registry.clear()
|
|
535
|
+
anchor = self._anchor_connection
|
|
536
|
+
self._anchor_connection = None
|
|
537
|
+
|
|
538
|
+
if connections:
|
|
539
|
+
for conn in connections:
|
|
540
|
+
with suppress(Exception):
|
|
541
|
+
raw_conn = getattr(conn.connection, "_conn", None)
|
|
542
|
+
if raw_conn is not None:
|
|
543
|
+
raw_conn.interrupt()
|
|
544
|
+
close_tasks = [asyncio.wait_for(conn.close(), timeout=self._operation_timeout) for conn in connections]
|
|
545
|
+
results = await asyncio.gather(*close_tasks, return_exceptions=True)
|
|
546
|
+
|
|
547
|
+
for i, result in enumerate(results):
|
|
548
|
+
if isinstance(result, Exception):
|
|
549
|
+
if isinstance(result, asyncio.TimeoutError):
|
|
550
|
+
await self._force_stop_connection(connections[i], reason="pool_close_timeout")
|
|
551
|
+
log_with_context(
|
|
552
|
+
logger,
|
|
553
|
+
logging.WARNING,
|
|
554
|
+
"pool.close.connection.error",
|
|
555
|
+
adapter=_ADAPTER_NAME,
|
|
556
|
+
pool_id=self._pool_id,
|
|
557
|
+
connection_id=connections[i].id,
|
|
558
|
+
error=str(result),
|
|
559
|
+
)
|
|
560
|
+
for conn in connections:
|
|
561
|
+
self._detach_worker(conn.connection)
|
|
562
|
+
if anchor is not None:
|
|
563
|
+
with suppress(Exception):
|
|
564
|
+
anchor.close()
|
|
565
|
+
await self._join_abandoned_workers()
|
|
566
|
+
|
|
567
|
+
async def _release_checked(self, connection: AiosqlitePoolConnection) -> None:
|
|
568
|
+
"""Return a connection whose transaction state was already finalized on the worker thread."""
|
|
569
|
+
if self._closed_event.is_set():
|
|
570
|
+
await self._retire_connection(connection)
|
|
571
|
+
return
|
|
572
|
+
if connection.id not in self._connection_registry:
|
|
573
|
+
log_with_context(
|
|
574
|
+
logger,
|
|
575
|
+
logging.WARNING,
|
|
576
|
+
"pool.connection.release.unknown",
|
|
577
|
+
adapter=_ADAPTER_NAME,
|
|
578
|
+
pool_id=self._pool_id,
|
|
579
|
+
connection_id=connection.id,
|
|
580
|
+
)
|
|
581
|
+
return
|
|
582
|
+
if (
|
|
583
|
+
not connection.is_healthy
|
|
584
|
+
or connection.is_closed
|
|
585
|
+
or getattr(connection.connection, "_connection", True) is None
|
|
586
|
+
):
|
|
587
|
+
connection.mark_unhealthy()
|
|
588
|
+
await self._retire_connection(connection, reason="unhealthy")
|
|
589
|
+
return
|
|
590
|
+
if self._reset_session_on_release:
|
|
591
|
+
reset_error: Exception | None = None
|
|
592
|
+
try:
|
|
593
|
+
await self._reset_connection(connection.connection)
|
|
594
|
+
except Exception as e:
|
|
595
|
+
reset_error = e
|
|
596
|
+
if reset_error is not None:
|
|
597
|
+
log_with_context(
|
|
598
|
+
logger,
|
|
599
|
+
logging.DEBUG,
|
|
600
|
+
"pool.connection.reset.error",
|
|
601
|
+
adapter=_ADAPTER_NAME,
|
|
602
|
+
pool_id=self._pool_id,
|
|
603
|
+
connection_id=connection.id,
|
|
604
|
+
error_type=type(reset_error).__name__,
|
|
605
|
+
)
|
|
606
|
+
connection.mark_unhealthy()
|
|
607
|
+
await self._retire_connection(connection, reason="reset_failed")
|
|
608
|
+
return
|
|
609
|
+
connection.idle_since = time.time()
|
|
610
|
+
self._queue.put_nowait(connection)
|
|
611
|
+
|
|
612
|
+
async def _reset_connection(self, raw_connection: "AiosqliteConnection") -> None:
|
|
613
|
+
if not self._reset_session_on_release:
|
|
614
|
+
return
|
|
615
|
+
runtime_pragmas = self._runtime_setup.get("pragmas", ()) if self._runtime_setup is not None else ()
|
|
616
|
+
await _reset_session_state(
|
|
617
|
+
raw_connection,
|
|
618
|
+
query_only=self._is_read_only,
|
|
619
|
+
foreign_keys=self._enable_foreign_keys,
|
|
620
|
+
busy_timeout=self._enable_optimizations,
|
|
621
|
+
runtime_pragmas=runtime_pragmas,
|
|
622
|
+
)
|
|
623
|
+
|
|
624
|
+
def _set_connect_proxy_daemon(self, connect_proxy: Any) -> None:
|
|
625
|
+
"""Set daemon mode on aiosqlite worker thread before await."""
|
|
626
|
+
try:
|
|
627
|
+
worker_thread = _worker_thread(connect_proxy)
|
|
628
|
+
if worker_thread is not None:
|
|
629
|
+
worker_thread.daemon = True
|
|
630
|
+
except Exception:
|
|
631
|
+
log_with_context(
|
|
632
|
+
logger,
|
|
633
|
+
logging.DEBUG,
|
|
634
|
+
"pool.connection.daemon.configure.error",
|
|
635
|
+
adapter=_ADAPTER_NAME,
|
|
636
|
+
pool_id=self._pool_id,
|
|
637
|
+
database=self._database_name,
|
|
638
|
+
)
|
|
639
|
+
|
|
640
|
+
def _detach_worker(self, connection: Any) -> None:
|
|
641
|
+
"""Make sure a connection's worker thread is stopping and keep it until the pool joins it.
|
|
642
|
+
|
|
643
|
+
Requests a stop when the connection has not already queued one, without awaiting the
|
|
644
|
+
result, so the call is safe inside a cancelled task.
|
|
645
|
+
|
|
646
|
+
Args:
|
|
647
|
+
connection: An aiosqlite connection or connection proxy.
|
|
648
|
+
"""
|
|
649
|
+
worker = _worker_thread(connection)
|
|
650
|
+
if worker is None or not worker.is_alive():
|
|
651
|
+
return
|
|
652
|
+
if getattr(connection, "_running", False):
|
|
653
|
+
with suppress(Exception):
|
|
654
|
+
connection.stop()
|
|
655
|
+
self._abandoned_workers = {thread for thread in self._abandoned_workers if thread.is_alive()}
|
|
656
|
+
self._abandoned_workers.add(worker)
|
|
657
|
+
|
|
658
|
+
async def _discard_connection(self, connection: "AiosqliteConnection") -> None:
|
|
659
|
+
"""Close a connection that never entered the pool and track its worker thread.
|
|
660
|
+
|
|
661
|
+
Args:
|
|
662
|
+
connection: The connection to discard.
|
|
663
|
+
"""
|
|
664
|
+
try:
|
|
665
|
+
with suppress(BaseException):
|
|
666
|
+
await connection.close()
|
|
667
|
+
finally:
|
|
668
|
+
self._detach_worker(connection)
|
|
669
|
+
|
|
670
|
+
async def _join_abandoned_workers(self) -> None:
|
|
671
|
+
"""Wait for tracked worker threads to exit, bounded by the operation timeout."""
|
|
672
|
+
workers = [thread for thread in self._abandoned_workers if thread.is_alive()]
|
|
673
|
+
self._abandoned_workers.clear()
|
|
674
|
+
if not workers:
|
|
675
|
+
return
|
|
676
|
+
await asyncio.to_thread(_join_threads, workers, self._operation_timeout)
|
|
677
|
+
for worker in workers:
|
|
678
|
+
if worker.is_alive():
|
|
679
|
+
log_with_context(
|
|
680
|
+
logger,
|
|
681
|
+
logging.WARNING,
|
|
682
|
+
"pool.close.worker.timeout",
|
|
683
|
+
adapter=_ADAPTER_NAME,
|
|
684
|
+
pool_id=self._pool_id,
|
|
685
|
+
worker=worker.name,
|
|
686
|
+
timeout_seconds=self._operation_timeout,
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
async def _force_stop_connection(self, connection: AiosqlitePoolConnection, *, reason: str) -> None:
|
|
690
|
+
"""Force-stop aiosqlite worker thread when graceful close times out."""
|
|
691
|
+
with suppress(Exception):
|
|
692
|
+
raw_conn = getattr(connection.connection, "_conn", None)
|
|
693
|
+
if raw_conn is not None:
|
|
694
|
+
raw_conn.interrupt()
|
|
695
|
+
try:
|
|
696
|
+
stop_method = getattr(connection.connection, "stop", None)
|
|
697
|
+
if stop_method is None:
|
|
698
|
+
log_with_context(
|
|
699
|
+
logger,
|
|
700
|
+
logging.DEBUG,
|
|
701
|
+
"pool.connection.force_stop.unavailable",
|
|
702
|
+
adapter=_ADAPTER_NAME,
|
|
703
|
+
pool_id=self._pool_id,
|
|
704
|
+
connection_id=connection.id,
|
|
705
|
+
reason=reason,
|
|
706
|
+
)
|
|
707
|
+
return
|
|
708
|
+
except Exception:
|
|
709
|
+
log_with_context(
|
|
710
|
+
logger,
|
|
711
|
+
logging.DEBUG,
|
|
712
|
+
"pool.connection.force_stop.unavailable",
|
|
713
|
+
adapter=_ADAPTER_NAME,
|
|
714
|
+
pool_id=self._pool_id,
|
|
715
|
+
connection_id=connection.id,
|
|
716
|
+
reason=reason,
|
|
717
|
+
)
|
|
718
|
+
return
|
|
719
|
+
|
|
720
|
+
try:
|
|
721
|
+
stop_result = stop_method()
|
|
722
|
+
if isawaitable(stop_result):
|
|
723
|
+
await asyncio.wait_for(stop_result, timeout=self._operation_timeout)
|
|
724
|
+
log_with_context(
|
|
725
|
+
logger,
|
|
726
|
+
logging.DEBUG,
|
|
727
|
+
"pool.connection.force_stop.success",
|
|
728
|
+
adapter=_ADAPTER_NAME,
|
|
729
|
+
pool_id=self._pool_id,
|
|
730
|
+
connection_id=connection.id,
|
|
731
|
+
reason=reason,
|
|
732
|
+
)
|
|
733
|
+
except TimeoutError:
|
|
734
|
+
log_with_context(
|
|
735
|
+
logger,
|
|
736
|
+
logging.WARNING,
|
|
737
|
+
"pool.connection.force_stop.timeout",
|
|
738
|
+
adapter=_ADAPTER_NAME,
|
|
739
|
+
pool_id=self._pool_id,
|
|
740
|
+
connection_id=connection.id,
|
|
741
|
+
timeout_seconds=self._operation_timeout,
|
|
742
|
+
reason=reason,
|
|
743
|
+
)
|
|
744
|
+
except Exception as e:
|
|
745
|
+
log_with_context(
|
|
746
|
+
logger,
|
|
747
|
+
logging.WARNING,
|
|
748
|
+
"pool.connection.force_stop.error",
|
|
749
|
+
adapter=_ADAPTER_NAME,
|
|
750
|
+
pool_id=self._pool_id,
|
|
751
|
+
connection_id=connection.id,
|
|
752
|
+
reason=reason,
|
|
753
|
+
error=str(e),
|
|
754
|
+
)
|
|
755
|
+
|
|
756
|
+
async def _create_connection(self) -> AiosqlitePoolConnection:
|
|
757
|
+
"""Create a new pooled connection and register it.
|
|
758
|
+
|
|
759
|
+
A connection whose creation finishes after the pool closed is closed and its worker
|
|
760
|
+
thread joined before the error is raised.
|
|
761
|
+
|
|
762
|
+
Returns:
|
|
763
|
+
New pool connection instance
|
|
764
|
+
|
|
765
|
+
Raises:
|
|
766
|
+
AiosqlitePoolClosedError: The pool closed while the connection was being created.
|
|
767
|
+
"""
|
|
768
|
+
connection = await self.new_connection()
|
|
769
|
+
registered = False
|
|
770
|
+
register_error: BaseException | None = None
|
|
771
|
+
pool_connection: AiosqlitePoolConnection | None = None
|
|
772
|
+
try:
|
|
773
|
+
pool_connection = AiosqlitePoolConnection(connection)
|
|
774
|
+
pool_connection.mark_as_idle()
|
|
775
|
+
|
|
776
|
+
_, is_shared_memory = _classify_memory_mode(self._connection_parameters)
|
|
777
|
+
raw_conn = getattr(connection, "_conn", None)
|
|
778
|
+
|
|
779
|
+
async with self._lock:
|
|
780
|
+
if not self.is_closed:
|
|
781
|
+
if (
|
|
782
|
+
is_shared_memory
|
|
783
|
+
and self._anchor_connection is None
|
|
784
|
+
and isinstance(raw_conn, sqlite3.Connection)
|
|
785
|
+
):
|
|
786
|
+
with suppress(Exception):
|
|
787
|
+
sqlite_kwargs = {
|
|
788
|
+
k: v for k, v in self._connection_parameters.items() if k != "iter_chunk_size"
|
|
789
|
+
}
|
|
790
|
+
sqlite_kwargs.setdefault("check_same_thread", False)
|
|
791
|
+
self._anchor_connection = sqlite3.connect(**sqlite_kwargs)
|
|
792
|
+
self._connection_registry[pool_connection.id] = pool_connection
|
|
793
|
+
registered = True
|
|
794
|
+
except BaseException as exc:
|
|
795
|
+
register_error = exc
|
|
796
|
+
if not registered:
|
|
797
|
+
await self._discard_connection(connection)
|
|
798
|
+
if self.is_closed:
|
|
799
|
+
await self._join_abandoned_workers()
|
|
800
|
+
if register_error is not None:
|
|
801
|
+
raise register_error
|
|
802
|
+
|
|
803
|
+
if not registered or pool_connection is None:
|
|
804
|
+
msg = "Pool closed during connection creation"
|
|
805
|
+
raise AiosqlitePoolClosedError(msg)
|
|
806
|
+
return pool_connection
|
|
807
|
+
|
|
808
|
+
async def _claim_if_healthy(self, connection: AiosqlitePoolConnection) -> bool:
|
|
809
|
+
"""Check if connection is healthy and claim it.
|
|
810
|
+
|
|
811
|
+
Uses passive health checks: connections idle less than health_check_interval
|
|
812
|
+
are assumed healthy based on their last known state. Active health checks
|
|
813
|
+
(SELECT 1) are only performed on long-idle connections.
|
|
814
|
+
|
|
815
|
+
Args:
|
|
816
|
+
connection: Connection to check and claim
|
|
817
|
+
|
|
818
|
+
Returns:
|
|
819
|
+
True if connection was claimed
|
|
820
|
+
"""
|
|
821
|
+
if connection.idle_time > self._idle_timeout:
|
|
822
|
+
await self._retire_connection(connection, reason="idle_timeout")
|
|
823
|
+
return False
|
|
824
|
+
|
|
825
|
+
if not connection.is_healthy:
|
|
826
|
+
await self._retire_connection(connection, reason="unhealthy")
|
|
827
|
+
return False
|
|
828
|
+
|
|
829
|
+
if connection.idle_time > self._health_check_interval:
|
|
830
|
+
health_timeout: TimeoutError | None = None
|
|
831
|
+
try:
|
|
832
|
+
is_alive = await asyncio.wait_for(connection.is_alive(), timeout=self._operation_timeout)
|
|
833
|
+
if not is_alive:
|
|
834
|
+
await self._retire_connection(connection, reason="health_check_failed")
|
|
835
|
+
return False
|
|
836
|
+
except TimeoutError as exc:
|
|
837
|
+
health_timeout = exc
|
|
838
|
+
if health_timeout is not None:
|
|
839
|
+
await self._retire_connection(connection, reason="health_check_timeout")
|
|
840
|
+
return False
|
|
841
|
+
|
|
842
|
+
connection.mark_as_in_use()
|
|
843
|
+
return True
|
|
844
|
+
|
|
845
|
+
async def _retire_connection(self, connection: AiosqlitePoolConnection, *, reason: str | None = None) -> None:
|
|
846
|
+
"""Retire a connection from the pool.
|
|
847
|
+
|
|
848
|
+
Args:
|
|
849
|
+
connection: Connection to retire
|
|
850
|
+
reason: Optional reason for retirement
|
|
851
|
+
"""
|
|
852
|
+
if reason:
|
|
853
|
+
log_with_context(
|
|
854
|
+
logger,
|
|
855
|
+
logging.DEBUG,
|
|
856
|
+
"pool.connection.retire",
|
|
857
|
+
adapter=_ADAPTER_NAME,
|
|
858
|
+
pool_id=self._pool_id,
|
|
859
|
+
connection_id=connection.id,
|
|
860
|
+
reason=reason,
|
|
861
|
+
)
|
|
862
|
+
async with self._lock:
|
|
863
|
+
self._connection_registry.pop(connection.id, None)
|
|
864
|
+
|
|
865
|
+
close_timed_out = False
|
|
866
|
+
try:
|
|
867
|
+
try:
|
|
868
|
+
await asyncio.wait_for(connection.close(), timeout=self._operation_timeout)
|
|
869
|
+
except TimeoutError:
|
|
870
|
+
close_timed_out = True
|
|
871
|
+
if close_timed_out:
|
|
872
|
+
log_with_context(
|
|
873
|
+
logger,
|
|
874
|
+
logging.WARNING,
|
|
875
|
+
"pool.connection.close.timeout",
|
|
876
|
+
adapter=_ADAPTER_NAME,
|
|
877
|
+
pool_id=self._pool_id,
|
|
878
|
+
connection_id=connection.id,
|
|
879
|
+
timeout_seconds=self._operation_timeout,
|
|
880
|
+
)
|
|
881
|
+
await self._force_stop_connection(connection, reason="retire_close_timeout")
|
|
882
|
+
finally:
|
|
883
|
+
self._detach_worker(connection.connection)
|
|
884
|
+
|
|
885
|
+
async def _try_provision_new_connection(self) -> "AiosqlitePoolConnection | None":
|
|
886
|
+
"""Try to create a new connection if under capacity.
|
|
887
|
+
|
|
888
|
+
Returns:
|
|
889
|
+
New connection if successful, None if at capacity
|
|
890
|
+
"""
|
|
891
|
+
async with self._lock:
|
|
892
|
+
if len(self._connection_registry) + self._in_flight_creations >= self._pool_size:
|
|
893
|
+
return None
|
|
894
|
+
self._in_flight_creations += 1
|
|
895
|
+
|
|
896
|
+
created: AiosqlitePoolConnection | None = None
|
|
897
|
+
create_error: BaseException | None = None
|
|
898
|
+
try:
|
|
899
|
+
created = await self._create_connection()
|
|
900
|
+
created.mark_as_in_use()
|
|
901
|
+
except BaseException as exc:
|
|
902
|
+
create_error = exc
|
|
903
|
+
log_with_context(
|
|
904
|
+
logger,
|
|
905
|
+
logging.WARNING,
|
|
906
|
+
"pool.connection.create.error",
|
|
907
|
+
adapter=_ADAPTER_NAME,
|
|
908
|
+
pool_id=self._pool_id,
|
|
909
|
+
database=self._database_name,
|
|
910
|
+
pool_size=len(self._connection_registry),
|
|
911
|
+
max_size=self._pool_size,
|
|
912
|
+
)
|
|
913
|
+
async with self._lock:
|
|
914
|
+
self._in_flight_creations -= 1
|
|
915
|
+
if create_error is not None:
|
|
916
|
+
raise create_error
|
|
917
|
+
return created
|
|
918
|
+
|
|
919
|
+
async def _wait_for_healthy_connection(self) -> AiosqlitePoolConnection:
|
|
920
|
+
"""Wait for a healthy connection to become available.
|
|
921
|
+
|
|
922
|
+
Returns:
|
|
923
|
+
Available healthy connection
|
|
924
|
+
|
|
925
|
+
Raises:
|
|
926
|
+
AiosqlitePoolClosedError: If pool is closed while waiting
|
|
927
|
+
"""
|
|
928
|
+
while True:
|
|
929
|
+
get_connection_task = asyncio.create_task(self._queue.get())
|
|
930
|
+
pool_closed_task = asyncio.create_task(self._closed_event.wait())
|
|
931
|
+
pending: set[asyncio.Task[Any]] = {get_connection_task, pool_closed_task}
|
|
932
|
+
claimed = False
|
|
933
|
+
claimed_connection: AiosqlitePoolConnection | None = None
|
|
934
|
+
wait_error: BaseException | None = None
|
|
935
|
+
|
|
936
|
+
try:
|
|
937
|
+
done, pending = await asyncio.wait(
|
|
938
|
+
{get_connection_task, pool_closed_task}, return_when=asyncio.FIRST_COMPLETED
|
|
939
|
+
)
|
|
940
|
+
|
|
941
|
+
if pool_closed_task in done:
|
|
942
|
+
msg = "Pool closed during connection acquisition"
|
|
943
|
+
wait_error = AiosqlitePoolClosedError(msg)
|
|
944
|
+
else:
|
|
945
|
+
connection = get_connection_task.result()
|
|
946
|
+
if await self._claim_if_healthy(connection):
|
|
947
|
+
claimed = True
|
|
948
|
+
claimed_connection = connection
|
|
949
|
+
|
|
950
|
+
except BaseException as exc:
|
|
951
|
+
wait_error = exc
|
|
952
|
+
for task in pending:
|
|
953
|
+
task.cancel()
|
|
954
|
+
with suppress(asyncio.CancelledError):
|
|
955
|
+
await task
|
|
956
|
+
if (
|
|
957
|
+
not claimed
|
|
958
|
+
and get_connection_task.done()
|
|
959
|
+
and not get_connection_task.cancelled()
|
|
960
|
+
and get_connection_task.exception() is None
|
|
961
|
+
):
|
|
962
|
+
unclaimed = get_connection_task.result()
|
|
963
|
+
if not unclaimed.is_closed and unclaimed.id in self._connection_registry:
|
|
964
|
+
if self._closed_event.is_set():
|
|
965
|
+
await self._retire_connection(unclaimed)
|
|
966
|
+
else:
|
|
967
|
+
with suppress(asyncio.QueueFull):
|
|
968
|
+
self._queue.put_nowait(unclaimed)
|
|
969
|
+
if wait_error is not None:
|
|
970
|
+
raise wait_error
|
|
971
|
+
if claimed_connection is not None:
|
|
972
|
+
return claimed_connection
|
|
973
|
+
|
|
974
|
+
async def _warm_pool(self) -> None:
|
|
975
|
+
"""Pre-create minimum connections for pool warming.
|
|
976
|
+
|
|
977
|
+
Creates connections up to min_size to avoid cold-start latency
|
|
978
|
+
on first requests.
|
|
979
|
+
"""
|
|
980
|
+
if self._warmed or self._min_size <= 0:
|
|
981
|
+
return
|
|
982
|
+
|
|
983
|
+
async with self._lock:
|
|
984
|
+
if self._warmed:
|
|
985
|
+
return
|
|
986
|
+
self._warmed = True
|
|
987
|
+
available_capacity = self._pool_size - (len(self._connection_registry) + self._in_flight_creations)
|
|
988
|
+
connections_needed = min(
|
|
989
|
+
self._min_size - (len(self._connection_registry) + self._in_flight_creations), available_capacity
|
|
990
|
+
)
|
|
991
|
+
if connections_needed <= 0:
|
|
992
|
+
return
|
|
993
|
+
self._in_flight_creations += connections_needed
|
|
994
|
+
|
|
995
|
+
warm_error: BaseException | None = None
|
|
996
|
+
try:
|
|
997
|
+
log_with_context(
|
|
998
|
+
logger,
|
|
999
|
+
logging.DEBUG,
|
|
1000
|
+
"pool.warmup.start",
|
|
1001
|
+
adapter=_ADAPTER_NAME,
|
|
1002
|
+
pool_id=self._pool_id,
|
|
1003
|
+
database=self._database_name,
|
|
1004
|
+
connections_needed=connections_needed,
|
|
1005
|
+
min_size=self._min_size,
|
|
1006
|
+
)
|
|
1007
|
+
tasks = [self._create_connection() for _ in range(connections_needed)]
|
|
1008
|
+
results = await asyncio.gather(*tasks, return_exceptions=True)
|
|
1009
|
+
|
|
1010
|
+
for result in results:
|
|
1011
|
+
if isinstance(result, AiosqlitePoolConnection):
|
|
1012
|
+
self._queue.put_nowait(result)
|
|
1013
|
+
elif isinstance(result, Exception):
|
|
1014
|
+
log_with_context(
|
|
1015
|
+
logger,
|
|
1016
|
+
logging.WARNING,
|
|
1017
|
+
"pool.warmup.connection.error",
|
|
1018
|
+
adapter=_ADAPTER_NAME,
|
|
1019
|
+
pool_id=self._pool_id,
|
|
1020
|
+
error=str(result),
|
|
1021
|
+
)
|
|
1022
|
+
except BaseException as exc:
|
|
1023
|
+
warm_error = exc
|
|
1024
|
+
async with self._lock:
|
|
1025
|
+
self._in_flight_creations -= connections_needed
|
|
1026
|
+
if warm_error is not None:
|
|
1027
|
+
raise warm_error
|
|
1028
|
+
|
|
1029
|
+
def _try_acquire_idle_connection(self) -> "AiosqlitePoolConnection | None":
|
|
1030
|
+
"""Synchronously claim a warm, recently-idle connection when available."""
|
|
1031
|
+
if self._closed_event.is_set() or (not self._warmed and self._min_size > 0) or self._queue.empty():
|
|
1032
|
+
return None
|
|
1033
|
+
connection = self._queue.get_nowait()
|
|
1034
|
+
idle_since = connection.idle_since
|
|
1035
|
+
if idle_since is not None and connection.is_healthy:
|
|
1036
|
+
idle_time = time.time() - idle_since
|
|
1037
|
+
if idle_time <= self._health_check_interval and idle_time <= self._idle_timeout:
|
|
1038
|
+
connection.idle_since = None
|
|
1039
|
+
return connection
|
|
1040
|
+
self._queue.put_nowait(connection)
|
|
1041
|
+
return None
|
|
1042
|
+
|
|
1043
|
+
async def _get_connection(self) -> AiosqlitePoolConnection:
|
|
1044
|
+
"""Run the three-phase connection acquisition cycle.
|
|
1045
|
+
|
|
1046
|
+
Returns:
|
|
1047
|
+
Available connection
|
|
1048
|
+
|
|
1049
|
+
Raises:
|
|
1050
|
+
AiosqlitePoolClosedError: If pool is closed
|
|
1051
|
+
"""
|
|
1052
|
+
if self._closed_event.is_set():
|
|
1053
|
+
msg = "Cannot acquire connection from closed pool"
|
|
1054
|
+
raise AiosqlitePoolClosedError(msg)
|
|
1055
|
+
|
|
1056
|
+
if not self._warmed and self._min_size > 0:
|
|
1057
|
+
await self._warm_pool()
|
|
1058
|
+
|
|
1059
|
+
while not self._queue.empty():
|
|
1060
|
+
connection = self._queue.get_nowait()
|
|
1061
|
+
if connection.idle_since is not None:
|
|
1062
|
+
idle_time = time.time() - connection.idle_since
|
|
1063
|
+
if idle_time <= self._health_check_interval and connection.is_healthy:
|
|
1064
|
+
connection.idle_since = None
|
|
1065
|
+
return connection
|
|
1066
|
+
claim_error: BaseException | None = None
|
|
1067
|
+
try:
|
|
1068
|
+
if await self._claim_if_healthy(connection):
|
|
1069
|
+
return connection
|
|
1070
|
+
except BaseException as exc:
|
|
1071
|
+
claim_error = exc
|
|
1072
|
+
if claim_error is not None:
|
|
1073
|
+
if not connection.is_closed and connection.id in self._connection_registry:
|
|
1074
|
+
await self._retire_connection(connection)
|
|
1075
|
+
raise claim_error
|
|
1076
|
+
|
|
1077
|
+
if len(self._connection_registry) + self._in_flight_creations < self._pool_size:
|
|
1078
|
+
new_connection = await self._try_provision_new_connection()
|
|
1079
|
+
if new_connection is not None:
|
|
1080
|
+
return new_connection
|
|
1081
|
+
|
|
1082
|
+
return await self._wait_for_healthy_connection()
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
def _worker_thread(connection: Any) -> "Thread | None":
|
|
1086
|
+
"""Return the worker thread behind an aiosqlite connection or connection proxy."""
|
|
1087
|
+
if isinstance(connection, Thread):
|
|
1088
|
+
return connection
|
|
1089
|
+
worker = getattr(connection, "_thread", None)
|
|
1090
|
+
return worker if isinstance(worker, Thread) else None
|
|
1091
|
+
|
|
1092
|
+
|
|
1093
|
+
def _join_threads(threads: "list[Thread]", timeout: float) -> None:
|
|
1094
|
+
"""Join threads until they exit or the shared timeout elapses."""
|
|
1095
|
+
deadline = time.monotonic() + timeout
|
|
1096
|
+
for thread in threads:
|
|
1097
|
+
thread.join(max(0.0, deadline - time.monotonic()))
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
async def _reset_session_state(
|
|
1101
|
+
connection: "AiosqliteConnection", *, query_only: bool, foreign_keys: bool, busy_timeout: bool, runtime_pragmas: Any
|
|
1102
|
+
) -> None:
|
|
1103
|
+
"""Remove session state a previous lease left on a pooled connection.
|
|
1104
|
+
|
|
1105
|
+
Args:
|
|
1106
|
+
connection: Connection whose lease just ended.
|
|
1107
|
+
query_only: Whether the pool enforces read-only queries.
|
|
1108
|
+
foreign_keys: Whether the pool enables foreign-key enforcement.
|
|
1109
|
+
busy_timeout: Whether the pool applies its busy-timeout optimization.
|
|
1110
|
+
runtime_pragmas: Configured ``(name, value)`` PRAGMA pairs applied after the baseline.
|
|
1111
|
+
"""
|
|
1112
|
+
original_factory = connection.row_factory
|
|
1113
|
+
connection.row_factory = None
|
|
1114
|
+
try:
|
|
1115
|
+
database_cursor = connection.execute("PRAGMA database_list")
|
|
1116
|
+
cursor = await database_cursor.__aenter__()
|
|
1117
|
+
database_error: BaseException | None = None
|
|
1118
|
+
databases: Any = ()
|
|
1119
|
+
try:
|
|
1120
|
+
databases = await cursor.fetchall()
|
|
1121
|
+
except BaseException as caught:
|
|
1122
|
+
database_error = caught
|
|
1123
|
+
await exit_async_context(database_cursor, database_error)
|
|
1124
|
+
for _, name, _file in databases:
|
|
1125
|
+
if name not in {"main", "temp"}:
|
|
1126
|
+
await _execute(connection, f"DETACH DATABASE {_quote_identifier(name)}")
|
|
1127
|
+
temp_cursor = connection.execute(
|
|
1128
|
+
"SELECT type, name FROM temp.sqlite_master WHERE name NOT LIKE 'sqlite!_%' ESCAPE '!'"
|
|
1129
|
+
)
|
|
1130
|
+
cursor = await temp_cursor.__aenter__()
|
|
1131
|
+
temp_error: BaseException | None = None
|
|
1132
|
+
temp_objects: Any = ()
|
|
1133
|
+
try:
|
|
1134
|
+
temp_objects = await cursor.fetchall()
|
|
1135
|
+
except BaseException as caught:
|
|
1136
|
+
temp_error = caught
|
|
1137
|
+
await exit_async_context(temp_cursor, temp_error)
|
|
1138
|
+
for object_type in _TEMP_OBJECT_DROP_ORDER:
|
|
1139
|
+
for found_type, name in temp_objects:
|
|
1140
|
+
if found_type == object_type:
|
|
1141
|
+
await _execute(connection, f"DROP {object_type.upper()} IF EXISTS temp.{_quote_identifier(name)}")
|
|
1142
|
+
for pragma_name, pragma_value in _SESSION_BASELINE_PRAGMAS:
|
|
1143
|
+
await _execute(connection, f"PRAGMA {pragma_name} = {pragma_value}")
|
|
1144
|
+
if busy_timeout:
|
|
1145
|
+
await _execute(connection, f"PRAGMA busy_timeout = {SQLITE_BUSY_TIMEOUT}")
|
|
1146
|
+
if query_only:
|
|
1147
|
+
await _execute(connection, "PRAGMA query_only = ON")
|
|
1148
|
+
if foreign_keys:
|
|
1149
|
+
await _execute(connection, "PRAGMA foreign_keys = ON")
|
|
1150
|
+
for pragma_name, pragma_value in runtime_pragmas:
|
|
1151
|
+
await _execute(connection, f"PRAGMA {pragma_name} = {pragma_value}")
|
|
1152
|
+
finally:
|
|
1153
|
+
connection.row_factory = original_factory
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
async def _execute(connection: "AiosqliteConnection", statement: str) -> None:
|
|
1157
|
+
cursor = await connection.execute(statement)
|
|
1158
|
+
await cursor.close()
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
def _quote_identifier(name: str) -> str:
|
|
1162
|
+
return '"' + name.replace('"', '""') + '"'
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
async def _attempt_wal_switch(connection: "AiosqliteConnection", attempt: int) -> bool:
|
|
1166
|
+
"""Attempt a single WAL mode switch, returning True on success."""
|
|
1167
|
+
locked = False
|
|
1168
|
+
try:
|
|
1169
|
+
cursor = await connection.execute("PRAGMA journal_mode = WAL")
|
|
1170
|
+
if cursor is not None and callable(getattr(cursor, "close", None)):
|
|
1171
|
+
with suppress(Exception):
|
|
1172
|
+
await cursor.close()
|
|
1173
|
+
except sqlite3.OperationalError as exc:
|
|
1174
|
+
if "locked" not in str(exc) or attempt == SQLITE_WAL_SWITCH_ATTEMPTS - 1:
|
|
1175
|
+
raise
|
|
1176
|
+
locked = True
|
|
1177
|
+
if locked:
|
|
1178
|
+
await asyncio.sleep(SQLITE_WAL_SWITCH_DELAY)
|
|
1179
|
+
return False
|
|
1180
|
+
return True
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
async def _enable_wal(connection: "AiosqliteConnection") -> None:
|
|
1184
|
+
"""Retry database and table locks briefly while switching to WAL mode."""
|
|
1185
|
+
for attempt in range(SQLITE_WAL_SWITCH_ATTEMPTS):
|
|
1186
|
+
if await _attempt_wal_switch(connection, attempt):
|
|
1187
|
+
return
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
def _dict_row_factory(cursor: Any, row: "tuple[Any, ...]") -> "dict[str, Any]":
|
|
1191
|
+
return {description[0]: row[index] for index, description in enumerate(cursor.description)}
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
def _resolve_row_factory(row_factory: Any) -> Any:
|
|
1195
|
+
if row_factory == "row":
|
|
1196
|
+
return sqlite3.Row
|
|
1197
|
+
if row_factory == "dict":
|
|
1198
|
+
return _dict_row_factory
|
|
1199
|
+
if row_factory == "tuple":
|
|
1200
|
+
return None
|
|
1201
|
+
return row_factory
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
def _register_runtime_objects(
|
|
1205
|
+
connection: "AiosqliteConnection",
|
|
1206
|
+
aggregates: "Sequence[dict[str, Any]]",
|
|
1207
|
+
collations: "Sequence[dict[str, Any]]",
|
|
1208
|
+
window_functions: "Sequence[dict[str, Any]]" = (),
|
|
1209
|
+
*,
|
|
1210
|
+
has_row_factory: bool = False,
|
|
1211
|
+
row_factory: Any = None,
|
|
1212
|
+
has_text_factory: bool = False,
|
|
1213
|
+
text_factory: Any = None,
|
|
1214
|
+
) -> None:
|
|
1215
|
+
"""Register custom aggregates, collations, window functions, and factories on the worker thread."""
|
|
1216
|
+
raw_connection = connection._conn
|
|
1217
|
+
for aggregate_config in aggregates:
|
|
1218
|
+
raw_connection.create_aggregate(
|
|
1219
|
+
aggregate_config["name"], aggregate_config["narg"], aggregate_config["aggregate_class"]
|
|
1220
|
+
)
|
|
1221
|
+
for collation_config in collations:
|
|
1222
|
+
raw_connection.create_collation(collation_config["name"], collation_config["func"])
|
|
1223
|
+
create_window_fn = getattr(raw_connection, "create_window_function", None)
|
|
1224
|
+
if window_functions and create_window_fn is None:
|
|
1225
|
+
msg = "Custom SQLite window functions require Python 3.11 or later"
|
|
1226
|
+
raise ImproperConfigurationError(msg)
|
|
1227
|
+
if create_window_fn is not None:
|
|
1228
|
+
for window_config in window_functions:
|
|
1229
|
+
create_window_fn(window_config["name"], window_config["narg"], window_config["window_class"])
|
|
1230
|
+
if has_row_factory:
|
|
1231
|
+
raw_connection.row_factory = row_factory
|
|
1232
|
+
if has_text_factory:
|
|
1233
|
+
raw_connection.text_factory = text_factory
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
async def _apply_runtime_setup(connection: "AiosqliteConnection", runtime_setup: "dict[str, Any]") -> None:
|
|
1237
|
+
pragmas = runtime_setup.get("pragmas", ())
|
|
1238
|
+
if pragmas:
|
|
1239
|
+
pragma_script = "\n".join(f"PRAGMA {pragma_name} = {pragma_value};" for pragma_name, pragma_value in pragmas)
|
|
1240
|
+
await connection.executescript(pragma_script)
|
|
1241
|
+
|
|
1242
|
+
extensions = runtime_setup.get("extensions")
|
|
1243
|
+
if extensions:
|
|
1244
|
+
await connection.enable_load_extension(True)
|
|
1245
|
+
load_error: BaseException | None = None
|
|
1246
|
+
try:
|
|
1247
|
+
for extension_path in extensions:
|
|
1248
|
+
await connection.load_extension(extension_path)
|
|
1249
|
+
except BaseException as exc:
|
|
1250
|
+
load_error = exc
|
|
1251
|
+
await connection.enable_load_extension(False)
|
|
1252
|
+
if load_error is not None:
|
|
1253
|
+
raise load_error
|
|
1254
|
+
|
|
1255
|
+
for function_config in runtime_setup.get("custom_functions", ()):
|
|
1256
|
+
await connection.create_function(
|
|
1257
|
+
function_config["name"],
|
|
1258
|
+
function_config["narg"],
|
|
1259
|
+
function_config["func"],
|
|
1260
|
+
deterministic=function_config.get("deterministic", False),
|
|
1261
|
+
)
|
|
1262
|
+
|
|
1263
|
+
aggregates = runtime_setup.get("custom_aggregates", ())
|
|
1264
|
+
collations = runtime_setup.get("custom_collations", ())
|
|
1265
|
+
window_functions = runtime_setup.get("custom_window_functions", ())
|
|
1266
|
+
has_row_factory = "row_factory" in runtime_setup
|
|
1267
|
+
resolved_row_factory = _resolve_row_factory(runtime_setup["row_factory"]) if has_row_factory else None
|
|
1268
|
+
has_text_factory = "text_factory" in runtime_setup
|
|
1269
|
+
resolved_text_factory = runtime_setup["text_factory"] if has_text_factory else None
|
|
1270
|
+
|
|
1271
|
+
if (
|
|
1272
|
+
aggregates
|
|
1273
|
+
or collations
|
|
1274
|
+
or window_functions
|
|
1275
|
+
or (
|
|
1276
|
+
(has_row_factory or has_text_factory)
|
|
1277
|
+
and isinstance(getattr(connection, "_conn", None), sqlite3.Connection)
|
|
1278
|
+
and callable(getattr(connection, "_execute", None))
|
|
1279
|
+
)
|
|
1280
|
+
):
|
|
1281
|
+
await run_on_worker_thread(
|
|
1282
|
+
connection,
|
|
1283
|
+
_register_runtime_objects,
|
|
1284
|
+
connection,
|
|
1285
|
+
aggregates,
|
|
1286
|
+
collations,
|
|
1287
|
+
window_functions,
|
|
1288
|
+
has_row_factory=has_row_factory,
|
|
1289
|
+
row_factory=resolved_row_factory,
|
|
1290
|
+
has_text_factory=has_text_factory,
|
|
1291
|
+
text_factory=resolved_text_factory,
|
|
1292
|
+
)
|
|
1293
|
+
else:
|
|
1294
|
+
if has_row_factory:
|
|
1295
|
+
connection.row_factory = resolved_row_factory
|
|
1296
|
+
if has_text_factory:
|
|
1297
|
+
connection.text_factory = cast("Any", resolved_text_factory)
|
|
1298
|
+
|
|
1299
|
+
authorizer_callback = runtime_setup.get("authorizer_callback")
|
|
1300
|
+
if authorizer_callback is not None:
|
|
1301
|
+
await connection.set_authorizer(authorizer_callback)
|
|
1302
|
+
|
|
1303
|
+
trace_callback = runtime_setup.get("trace_callback")
|
|
1304
|
+
if trace_callback is not None:
|
|
1305
|
+
await connection.set_trace_callback(trace_callback)
|
|
1306
|
+
|
|
1307
|
+
progress_handler = runtime_setup.get("progress_handler")
|
|
1308
|
+
if progress_handler is not None:
|
|
1309
|
+
await connection.set_progress_handler(progress_handler, runtime_setup.get("progress_handler_interval", 1000))
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
def _classify_memory_mode(connection_parameters: "Mapping[str, Any]") -> "tuple[bool, bool]":
|
|
1313
|
+
"""Classify whether SQLite connection parameters target a memory and shared-cache database."""
|
|
1314
|
+
database = str(connection_parameters.get("database", ":memory:"))
|
|
1315
|
+
if database == ":memory:":
|
|
1316
|
+
return True, False
|
|
1317
|
+
if not connection_parameters.get("uri") or not database.startswith("file:"):
|
|
1318
|
+
return False, False
|
|
1319
|
+
parts = urlsplit(database)
|
|
1320
|
+
query = parse_qs(parts.query)
|
|
1321
|
+
is_memory_db = unquote(parts.path) == ":memory:" or "memory" in query.get("mode", [])
|
|
1322
|
+
is_shared_memory = is_memory_db and "shared" in query.get("cache", [])
|
|
1323
|
+
return is_memory_db, is_shared_memory
|