sqlspec 0.47.0__cp314-cp314-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.
- f68e0789eb443ecb1c2c__mypyc.cp314-win_amd64.pyd +0 -0
- sqlspec/__init__.py +167 -0
- sqlspec/__main__.py +12 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_typing.py +714 -0
- sqlspec/adapters/__init__.py +0 -0
- sqlspec/adapters/adbc/__init__.py +13 -0
- sqlspec/adapters/adbc/_typing.py +106 -0
- sqlspec/adapters/adbc/adk/__init__.py +5 -0
- sqlspec/adapters/adbc/adk/store.py +1280 -0
- sqlspec/adapters/adbc/config.py +378 -0
- sqlspec/adapters/adbc/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/core.py +922 -0
- sqlspec/adapters/adbc/data_dictionary.py +339 -0
- sqlspec/adapters/adbc/driver.py +534 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +285 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +534 -0
- sqlspec/adapters/adbc/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/type_converter.py +142 -0
- sqlspec/adapters/aiomysql/__init__.py +21 -0
- sqlspec/adapters/aiomysql/_typing.py +137 -0
- sqlspec/adapters/aiomysql/adk/__init__.py +5 -0
- sqlspec/adapters/aiomysql/adk/store.py +678 -0
- sqlspec/adapters/aiomysql/config.py +305 -0
- sqlspec/adapters/aiomysql/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/core.py +536 -0
- sqlspec/adapters/aiomysql/data_dictionary.py +121 -0
- sqlspec/adapters/aiomysql/driver.py +386 -0
- sqlspec/adapters/aiomysql/events/__init__.py +5 -0
- sqlspec/adapters/aiomysql/events/store.py +104 -0
- sqlspec/adapters/aiomysql/litestar/__init__.py +5 -0
- sqlspec/adapters/aiomysql/litestar/store.py +314 -0
- sqlspec/adapters/aiosqlite/__init__.py +26 -0
- sqlspec/adapters/aiosqlite/_typing.py +109 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +829 -0
- sqlspec/adapters/aiosqlite/config.py +315 -0
- sqlspec/adapters/aiosqlite/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/core.py +315 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +202 -0
- sqlspec/adapters/aiosqlite/driver.py +311 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +20 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +279 -0
- sqlspec/adapters/aiosqlite/pool.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/pool.py +734 -0
- sqlspec/adapters/asyncmy/__init__.py +21 -0
- sqlspec/adapters/asyncmy/_typing.py +113 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +644 -0
- sqlspec/adapters/asyncmy/config.py +307 -0
- sqlspec/adapters/asyncmy/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/core.py +538 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +122 -0
- sqlspec/adapters/asyncmy/driver.py +391 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +104 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +296 -0
- sqlspec/adapters/asyncpg/__init__.py +26 -0
- sqlspec/adapters/asyncpg/_typing.py +103 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +483 -0
- sqlspec/adapters/asyncpg/config.py +575 -0
- sqlspec/adapters/asyncpg/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/core.py +480 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +157 -0
- sqlspec/adapters/asyncpg/driver.py +487 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/_hub.py +181 -0
- sqlspec/adapters/asyncpg/events/backend.py +210 -0
- sqlspec/adapters/asyncpg/events/store.py +40 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +251 -0
- sqlspec/adapters/bigquery/__init__.py +15 -0
- sqlspec/adapters/bigquery/_typing.py +108 -0
- sqlspec/adapters/bigquery/config.py +362 -0
- sqlspec/adapters/bigquery/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/core.py +768 -0
- sqlspec/adapters/bigquery/data_dictionary.py +120 -0
- sqlspec/adapters/bigquery/driver.py +542 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +139 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +325 -0
- sqlspec/adapters/bigquery/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/type_converter.py +107 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +26 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +73 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +465 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +248 -0
- sqlspec/adapters/cockroach_asyncpg/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +55 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +110 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +142 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +142 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +39 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +137 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +13 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +1039 -0
- sqlspec/adapters/cockroach_psycopg/config.py +511 -0
- sqlspec/adapters/cockroach_psycopg/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +63 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +220 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +273 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +6 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +3 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +327 -0
- sqlspec/adapters/duckdb/__init__.py +29 -0
- sqlspec/adapters/duckdb/_typing.py +104 -0
- sqlspec/adapters/duckdb/adk/__init__.py +14 -0
- sqlspec/adapters/duckdb/adk/store.py +935 -0
- sqlspec/adapters/duckdb/config.py +386 -0
- sqlspec/adapters/duckdb/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/core.py +332 -0
- sqlspec/adapters/duckdb/data_dictionary.py +140 -0
- sqlspec/adapters/duckdb/driver.py +426 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +57 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +330 -0
- sqlspec/adapters/duckdb/pool.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/pool.py +350 -0
- sqlspec/adapters/duckdb/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/type_converter.py +118 -0
- sqlspec/adapters/mysqlconnector/__init__.py +39 -0
- sqlspec/adapters/mysqlconnector/_typing.py +186 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +15 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +1183 -0
- sqlspec/adapters/mysqlconnector/config.py +421 -0
- sqlspec/adapters/mysqlconnector/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/core.py +472 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +230 -0
- sqlspec/adapters/mysqlconnector/driver.py +516 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +98 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +5 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +426 -0
- sqlspec/adapters/oracledb/__init__.py +39 -0
- sqlspec/adapters/oracledb/_json_handlers.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_json_handlers.py +196 -0
- sqlspec/adapters/oracledb/_param_types.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_param_types.py +46 -0
- sqlspec/adapters/oracledb/_typing.py +258 -0
- sqlspec/adapters/oracledb/_uuid_handlers.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +163 -0
- sqlspec/adapters/oracledb/_vector_handlers.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_vector_handlers.py +228 -0
- sqlspec/adapters/oracledb/adk/__init__.py +21 -0
- sqlspec/adapters/oracledb/adk/store.py +2453 -0
- sqlspec/adapters/oracledb/config.py +575 -0
- sqlspec/adapters/oracledb/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/core.py +820 -0
- sqlspec/adapters/oracledb/data_dictionary.py +404 -0
- sqlspec/adapters/oracledb/driver.py +1277 -0
- sqlspec/adapters/oracledb/events/__init__.py +16 -0
- sqlspec/adapters/oracledb/events/_hub.py +345 -0
- sqlspec/adapters/oracledb/events/backend.py +300 -0
- sqlspec/adapters/oracledb/events/store.py +420 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +5 -0
- sqlspec/adapters/oracledb/litestar/store.py +781 -0
- sqlspec/adapters/oracledb/migrations.py +539 -0
- sqlspec/adapters/oracledb/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/type_converter.py +211 -0
- sqlspec/adapters/psqlpy/__init__.py +18 -0
- sqlspec/adapters/psqlpy/_typing.py +121 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +591 -0
- sqlspec/adapters/psqlpy/config.py +376 -0
- sqlspec/adapters/psqlpy/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/core.py +694 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +121 -0
- sqlspec/adapters/psqlpy/driver.py +411 -0
- sqlspec/adapters/psqlpy/events/__init__.py +6 -0
- sqlspec/adapters/psqlpy/events/_hub.py +204 -0
- sqlspec/adapters/psqlpy/events/backend.py +210 -0
- sqlspec/adapters/psqlpy/events/store.py +20 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +113 -0
- sqlspec/adapters/psycopg/__init__.py +38 -0
- sqlspec/adapters/psycopg/_typing.py +218 -0
- sqlspec/adapters/psycopg/adk/__init__.py +10 -0
- sqlspec/adapters/psycopg/adk/store.py +1106 -0
- sqlspec/adapters/psycopg/config.py +695 -0
- sqlspec/adapters/psycopg/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/core.py +520 -0
- sqlspec/adapters/psycopg/data_dictionary.py +278 -0
- sqlspec/adapters/psycopg/driver.py +1033 -0
- sqlspec/adapters/psycopg/events/__init__.py +20 -0
- sqlspec/adapters/psycopg/events/_hub.py +388 -0
- sqlspec/adapters/psycopg/events/backend.py +398 -0
- sqlspec/adapters/psycopg/events/store.py +42 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +554 -0
- sqlspec/adapters/psycopg/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/type_converter.py +93 -0
- sqlspec/adapters/pymysql/__init__.py +21 -0
- sqlspec/adapters/pymysql/_typing.py +92 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +657 -0
- sqlspec/adapters/pymysql/config.py +176 -0
- sqlspec/adapters/pymysql/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/core.py +469 -0
- sqlspec/adapters/pymysql/data_dictionary.py +120 -0
- sqlspec/adapters/pymysql/driver.py +271 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +50 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +232 -0
- sqlspec/adapters/pymysql/pool.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/pool.py +184 -0
- sqlspec/adapters/spanner/__init__.py +33 -0
- sqlspec/adapters/spanner/_typing.py +102 -0
- sqlspec/adapters/spanner/adk/__init__.py +5 -0
- sqlspec/adapters/spanner/adk/store.py +758 -0
- sqlspec/adapters/spanner/config.py +355 -0
- sqlspec/adapters/spanner/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/core.py +263 -0
- sqlspec/adapters/spanner/data_dictionary.py +120 -0
- sqlspec/adapters/spanner/driver.py +407 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +187 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +291 -0
- sqlspec/adapters/spanner/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/type_converter.py +342 -0
- sqlspec/adapters/sqlite/__init__.py +19 -0
- sqlspec/adapters/sqlite/_typing.py +123 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +992 -0
- sqlspec/adapters/sqlite/config.py +240 -0
- sqlspec/adapters/sqlite/core.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/core.py +357 -0
- sqlspec/adapters/sqlite/data_dictionary.py +198 -0
- sqlspec/adapters/sqlite/driver.py +527 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +20 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +316 -0
- sqlspec/adapters/sqlite/pool.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/pool.py +237 -0
- sqlspec/adapters/sqlite/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/base.py +832 -0
- sqlspec/builder/__init__.py +181 -0
- sqlspec/builder/_base.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_base.py +1071 -0
- sqlspec/builder/_column.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_column.py +521 -0
- sqlspec/builder/_ddl.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_ddl.py +1691 -0
- sqlspec/builder/_delete.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_delete.py +95 -0
- sqlspec/builder/_dml.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_dml.py +386 -0
- sqlspec/builder/_explain.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_explain.py +579 -0
- sqlspec/builder/_expression_wrappers.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_expression_wrappers.py +46 -0
- sqlspec/builder/_factory.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_factory.py +1884 -0
- sqlspec/builder/_insert.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_insert.py +405 -0
- sqlspec/builder/_join.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_join.py +489 -0
- sqlspec/builder/_merge.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_merge.py +823 -0
- sqlspec/builder/_parsing_utils.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_parsing_utils.py +295 -0
- sqlspec/builder/_select.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_select.py +1666 -0
- sqlspec/builder/_temporal.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_temporal.py +167 -0
- sqlspec/builder/_update.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_update.py +173 -0
- sqlspec/builder/_vector_distance.cp314-win_amd64.pyd +0 -0
- sqlspec/builder/_vector_distance.py +330 -0
- sqlspec/cli.py +1095 -0
- sqlspec/config.py +2383 -0
- sqlspec/core/__init__.py +372 -0
- sqlspec/core/_correlation.cp314-win_amd64.pyd +0 -0
- sqlspec/core/_correlation.py +176 -0
- sqlspec/core/_pagination.py +42 -0
- sqlspec/core/_pool.cp314-win_amd64.pyd +0 -0
- sqlspec/core/_pool.py +76 -0
- sqlspec/core/cache.cp314-win_amd64.pyd +0 -0
- sqlspec/core/cache.py +1085 -0
- sqlspec/core/compiler.cp314-win_amd64.pyd +0 -0
- sqlspec/core/compiler.py +1090 -0
- sqlspec/core/config_runtime.cp314-win_amd64.pyd +0 -0
- sqlspec/core/config_runtime.py +174 -0
- sqlspec/core/explain.cp314-win_amd64.pyd +0 -0
- sqlspec/core/explain.py +275 -0
- sqlspec/core/filters.cp314-win_amd64.pyd +0 -0
- sqlspec/core/filters.py +969 -0
- sqlspec/core/hashing.cp314-win_amd64.pyd +0 -0
- sqlspec/core/hashing.py +266 -0
- sqlspec/core/metrics.cp314-win_amd64.pyd +0 -0
- sqlspec/core/metrics.py +83 -0
- sqlspec/core/parameters/__init__.py +72 -0
- sqlspec/core/parameters/_alignment.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_alignment.py +283 -0
- sqlspec/core/parameters/_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_converter.py +554 -0
- sqlspec/core/parameters/_processor.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_processor.py +1182 -0
- sqlspec/core/parameters/_registry.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_registry.py +206 -0
- sqlspec/core/parameters/_transformers.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_transformers.py +324 -0
- sqlspec/core/parameters/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_types.py +536 -0
- sqlspec/core/parameters/_validator.cp314-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_validator.py +171 -0
- sqlspec/core/pipeline.cp314-win_amd64.pyd +0 -0
- sqlspec/core/pipeline.py +333 -0
- sqlspec/core/query_modifiers.cp314-win_amd64.pyd +0 -0
- sqlspec/core/query_modifiers.py +508 -0
- sqlspec/core/result/__init__.py +25 -0
- sqlspec/core/result/_base.cp314-win_amd64.pyd +0 -0
- sqlspec/core/result/_base.py +1232 -0
- sqlspec/core/result/_io.cp314-win_amd64.pyd +0 -0
- sqlspec/core/result/_io.py +28 -0
- sqlspec/core/splitter.cp314-win_amd64.pyd +0 -0
- sqlspec/core/splitter.py +1021 -0
- sqlspec/core/sqlcommenter.cp314-win_amd64.pyd +0 -0
- sqlspec/core/sqlcommenter.py +249 -0
- sqlspec/core/stack.cp314-win_amd64.pyd +0 -0
- sqlspec/core/stack.py +163 -0
- sqlspec/core/statement.cp314-win_amd64.pyd +0 -0
- sqlspec/core/statement.py +1865 -0
- sqlspec/core/type_converter.cp314-win_amd64.pyd +0 -0
- sqlspec/core/type_converter.py +340 -0
- sqlspec/data_dictionary/__init__.py +22 -0
- sqlspec/data_dictionary/_loader.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_loader.py +138 -0
- sqlspec/data_dictionary/_registry.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_registry.py +74 -0
- sqlspec/data_dictionary/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_types.py +121 -0
- sqlspec/data_dictionary/dialects/__init__.py +21 -0
- sqlspec/data_dictionary/dialects/bigquery.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/bigquery.py +81 -0
- sqlspec/data_dictionary/dialects/cockroachdb.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb.py +54 -0
- sqlspec/data_dictionary/dialects/duckdb.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/duckdb.py +47 -0
- sqlspec/data_dictionary/dialects/mysql.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mysql.py +53 -0
- sqlspec/data_dictionary/dialects/oracle.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/oracle.py +197 -0
- sqlspec/data_dictionary/dialects/postgres.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/postgres.py +69 -0
- sqlspec/data_dictionary/dialects/spanner.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/spanner.py +37 -0
- sqlspec/data_dictionary/dialects/sqlite.cp314-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlite.py +59 -0
- sqlspec/data_dictionary/sql/.gitkeep +0 -0
- sqlspec/data_dictionary/sql/bigquery/columns.sql +23 -0
- sqlspec/data_dictionary/sql/bigquery/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/sql/bigquery/indexes.sql +19 -0
- sqlspec/data_dictionary/sql/bigquery/tables.sql +33 -0
- sqlspec/data_dictionary/sql/bigquery/version.sql +3 -0
- sqlspec/data_dictionary/sql/cockroachdb/columns.sql +34 -0
- sqlspec/data_dictionary/sql/cockroachdb/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/sql/cockroachdb/indexes.sql +32 -0
- sqlspec/data_dictionary/sql/cockroachdb/tables.sql +44 -0
- sqlspec/data_dictionary/sql/cockroachdb/version.sql +3 -0
- sqlspec/data_dictionary/sql/duckdb/columns.sql +23 -0
- sqlspec/data_dictionary/sql/duckdb/foreign_keys.sql +36 -0
- sqlspec/data_dictionary/sql/duckdb/indexes.sql +19 -0
- sqlspec/data_dictionary/sql/duckdb/tables.sql +38 -0
- sqlspec/data_dictionary/sql/duckdb/version.sql +3 -0
- sqlspec/data_dictionary/sql/mysql/columns.sql +23 -0
- sqlspec/data_dictionary/sql/mysql/foreign_keys.sql +28 -0
- sqlspec/data_dictionary/sql/mysql/indexes.sql +26 -0
- sqlspec/data_dictionary/sql/mysql/tables.sql +33 -0
- sqlspec/data_dictionary/sql/mysql/version.sql +3 -0
- sqlspec/data_dictionary/sql/oracle/columns.sql +23 -0
- sqlspec/data_dictionary/sql/oracle/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/sql/oracle/indexes.sql +44 -0
- sqlspec/data_dictionary/sql/oracle/tables.sql +25 -0
- sqlspec/data_dictionary/sql/oracle/version.sql +20 -0
- sqlspec/data_dictionary/sql/postgres/columns.sql +34 -0
- sqlspec/data_dictionary/sql/postgres/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/sql/postgres/indexes.sql +56 -0
- sqlspec/data_dictionary/sql/postgres/tables.sql +44 -0
- sqlspec/data_dictionary/sql/postgres/version.sql +3 -0
- sqlspec/data_dictionary/sql/spanner/columns.sql +23 -0
- sqlspec/data_dictionary/sql/spanner/foreign_keys.sql +70 -0
- sqlspec/data_dictionary/sql/spanner/indexes.sql +30 -0
- sqlspec/data_dictionary/sql/spanner/tables.sql +9 -0
- sqlspec/data_dictionary/sql/spanner/version.sql +3 -0
- sqlspec/data_dictionary/sql/sqlite/columns.sql +23 -0
- sqlspec/data_dictionary/sql/sqlite/foreign_keys.sql +22 -0
- sqlspec/data_dictionary/sql/sqlite/indexes.sql +7 -0
- sqlspec/data_dictionary/sql/sqlite/tables.sql +28 -0
- sqlspec/data_dictionary/sql/sqlite/version.sql +3 -0
- sqlspec/dialects/__init__.py +22 -0
- sqlspec/dialects/_compat.cp314-win_amd64.pyd +0 -0
- sqlspec/dialects/_compat.py +14 -0
- sqlspec/dialects/postgres/__init__.py +9 -0
- sqlspec/dialects/postgres/_generators.cp314-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_generators.py +57 -0
- sqlspec/dialects/postgres/_operators.cp314-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_operators.py +81 -0
- sqlspec/dialects/postgres/_paradedb.py +50 -0
- sqlspec/dialects/postgres/_pgvector.py +36 -0
- sqlspec/dialects/spanner/__init__.py +6 -0
- sqlspec/dialects/spanner/_generators.cp314-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_generators.py +206 -0
- sqlspec/dialects/spanner/_spangres.py +77 -0
- sqlspec/dialects/spanner/_spanner.py +179 -0
- sqlspec/driver/__init__.py +49 -0
- sqlspec/driver/_async.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_async.py +1830 -0
- sqlspec/driver/_common.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_common.py +2292 -0
- sqlspec/driver/_exception_handler.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_exception_handler.py +108 -0
- sqlspec/driver/_query_cache.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_query_cache.py +96 -0
- sqlspec/driver/_sql_helpers.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_sql_helpers.py +139 -0
- sqlspec/driver/_storage_helpers.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_storage_helpers.py +153 -0
- sqlspec/driver/_sync.cp314-win_amd64.pyd +0 -0
- sqlspec/driver/_sync.py +1817 -0
- sqlspec/exceptions.cp314-win_amd64.pyd +0 -0
- sqlspec/exceptions.py +480 -0
- sqlspec/extensions/__init__.py +0 -0
- sqlspec/extensions/adk/__init__.py +84 -0
- sqlspec/extensions/adk/_config_utils.py +199 -0
- sqlspec/extensions/adk/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_types.py +41 -0
- sqlspec/extensions/adk/artifact/__init__.py +57 -0
- sqlspec/extensions/adk/artifact/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/artifact/_types.py +32 -0
- sqlspec/extensions/adk/artifact/service.py +508 -0
- sqlspec/extensions/adk/artifact/store.py +361 -0
- sqlspec/extensions/adk/converters.py +212 -0
- sqlspec/extensions/adk/memory/__init__.py +69 -0
- sqlspec/extensions/adk/memory/_types.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/memory/_types.py +30 -0
- sqlspec/extensions/adk/memory/converters.py +225 -0
- sqlspec/extensions/adk/memory/service.py +316 -0
- sqlspec/extensions/adk/memory/store.py +525 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +184 -0
- sqlspec/extensions/adk/migrations/__init__.py +0 -0
- sqlspec/extensions/adk/service.py +279 -0
- sqlspec/extensions/adk/store.py +590 -0
- sqlspec/extensions/events/__init__.py +51 -0
- sqlspec/extensions/events/_channel.py +703 -0
- sqlspec/extensions/events/_hints.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_hints.py +45 -0
- sqlspec/extensions/events/_models.py +23 -0
- sqlspec/extensions/events/_payload.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_payload.py +69 -0
- sqlspec/extensions/events/_protocols.py +134 -0
- sqlspec/extensions/events/_queue.py +462 -0
- sqlspec/extensions/events/_store.py +209 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +59 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/fastapi/__init__.py +22 -0
- sqlspec/extensions/fastapi/extension.py +391 -0
- sqlspec/extensions/fastapi/providers.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/fastapi/providers.py +712 -0
- sqlspec/extensions/flask/__init__.py +38 -0
- sqlspec/extensions/flask/_state.py +87 -0
- sqlspec/extensions/flask/_utils.py +71 -0
- sqlspec/extensions/flask/extension.py +539 -0
- sqlspec/extensions/litestar/__init__.py +31 -0
- sqlspec/extensions/litestar/_utils.py +52 -0
- sqlspec/extensions/litestar/channels.py +165 -0
- sqlspec/extensions/litestar/cli.py +102 -0
- sqlspec/extensions/litestar/config.py +90 -0
- sqlspec/extensions/litestar/handlers.py +316 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +137 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/plugin.py +1066 -0
- sqlspec/extensions/litestar/providers.cp314-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/providers.py +784 -0
- sqlspec/extensions/litestar/store.py +298 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +113 -0
- sqlspec/extensions/sanic/__init__.py +19 -0
- sqlspec/extensions/sanic/_state.py +43 -0
- sqlspec/extensions/sanic/_utils.py +127 -0
- sqlspec/extensions/sanic/extension.py +647 -0
- sqlspec/extensions/starlette/__init__.py +22 -0
- sqlspec/extensions/starlette/_state.py +42 -0
- sqlspec/extensions/starlette/_utils.py +96 -0
- sqlspec/extensions/starlette/extension.py +374 -0
- sqlspec/extensions/starlette/middleware.py +281 -0
- sqlspec/loader.cp314-win_amd64.pyd +0 -0
- sqlspec/loader.py +727 -0
- sqlspec/migrations/__init__.py +39 -0
- sqlspec/migrations/base.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/base.py +862 -0
- sqlspec/migrations/commands.py +2151 -0
- sqlspec/migrations/context.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/context.py +157 -0
- sqlspec/migrations/fix.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/fix.py +204 -0
- sqlspec/migrations/loaders.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/loaders.py +443 -0
- sqlspec/migrations/runner.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/runner.py +1195 -0
- sqlspec/migrations/squash.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/squash.py +490 -0
- sqlspec/migrations/templates.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/templates.py +234 -0
- sqlspec/migrations/tracker.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/tracker.py +792 -0
- sqlspec/migrations/utils.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/utils.py +256 -0
- sqlspec/migrations/validation.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/validation.py +359 -0
- sqlspec/migrations/version.cp314-win_amd64.pyd +0 -0
- sqlspec/migrations/version.py +446 -0
- sqlspec/observability/__init__.py +57 -0
- sqlspec/observability/_common.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_common.py +77 -0
- sqlspec/observability/_config.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_config.py +364 -0
- sqlspec/observability/_diagnostics.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_diagnostics.py +74 -0
- sqlspec/observability/_dispatcher.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_dispatcher.py +200 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_aws.py +102 -0
- sqlspec/observability/_formatters/_azure.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_azure.py +96 -0
- sqlspec/observability/_formatters/_base.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_base.py +57 -0
- sqlspec/observability/_formatters/_gcp.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_gcp.py +131 -0
- sqlspec/observability/_formatting.py +58 -0
- sqlspec/observability/_observer.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_observer.py +361 -0
- sqlspec/observability/_runtime.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_runtime.py +461 -0
- sqlspec/observability/_sampling.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_sampling.py +188 -0
- sqlspec/observability/_spans.cp314-win_amd64.pyd +0 -0
- sqlspec/observability/_spans.py +161 -0
- sqlspec/protocols.py +955 -0
- sqlspec/py.typed +0 -0
- sqlspec/service.py +433 -0
- sqlspec/storage/__init__.py +48 -0
- sqlspec/storage/_arrow_payload.py +68 -0
- sqlspec/storage/_paths.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/_paths.py +58 -0
- sqlspec/storage/_utils.py +46 -0
- sqlspec/storage/backends/__init__.py +1 -0
- sqlspec/storage/backends/base.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/backends/base.py +374 -0
- sqlspec/storage/backends/fsspec.py +574 -0
- sqlspec/storage/backends/local.py +468 -0
- sqlspec/storage/backends/obstore.py +956 -0
- sqlspec/storage/errors.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/errors.py +102 -0
- sqlspec/storage/pipeline.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/pipeline.py +628 -0
- sqlspec/storage/registry.cp314-win_amd64.pyd +0 -0
- sqlspec/storage/registry.py +329 -0
- sqlspec/typing.py +405 -0
- sqlspec/utils/__init__.py +7 -0
- sqlspec/utils/arrow_helpers.py +384 -0
- sqlspec/utils/config_tools.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/config_tools.py +314 -0
- sqlspec/utils/correlation.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/correlation.py +134 -0
- sqlspec/utils/deprecation.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/deprecation.py +157 -0
- sqlspec/utils/dispatch.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/dispatch.py +101 -0
- sqlspec/utils/fixtures.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/fixtures.py +260 -0
- sqlspec/utils/logging.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/logging.py +251 -0
- sqlspec/utils/module_loader.py +306 -0
- sqlspec/utils/portal.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/portal.py +377 -0
- sqlspec/utils/schema.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/schema.py +1040 -0
- sqlspec/utils/serializers/__init__.py +30 -0
- sqlspec/utils/serializers/_json.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_json.py +415 -0
- sqlspec/utils/serializers/_numpy.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_numpy.py +65 -0
- sqlspec/utils/serializers/_schema.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_schema.py +285 -0
- sqlspec/utils/singleton.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/singleton.py +41 -0
- sqlspec/utils/sync_tools.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/sync_tools.py +316 -0
- sqlspec/utils/text.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/text.py +109 -0
- sqlspec/utils/type_converters.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/type_converters.py +216 -0
- sqlspec/utils/type_guards.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/type_guards.py +1508 -0
- sqlspec/utils/uuids.cp314-win_amd64.pyd +0 -0
- sqlspec/utils/uuids.py +241 -0
- sqlspec-0.47.0.dist-info/METADATA +202 -0
- sqlspec-0.47.0.dist-info/RECORD +621 -0
- sqlspec-0.47.0.dist-info/WHEEL +4 -0
- sqlspec-0.47.0.dist-info/entry_points.txt +6 -0
- sqlspec-0.47.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Typed parameter wrappers for explicit Oracle LOB / JSON binding.
|
|
2
|
+
|
|
3
|
+
These slot-based wrappers are an opt-in escape hatch for power users who need
|
|
4
|
+
deterministic LOB or JSON routing regardless of the size-based heuristics in
|
|
5
|
+
:func:`coerce_large_parameters_sync` / :func:`coerce_large_parameters_async`.
|
|
6
|
+
|
|
7
|
+
Wrap a parameter value to express explicit intent:
|
|
8
|
+
|
|
9
|
+
* :class:`OracleClob` — bind as ``DB_TYPE_CLOB`` regardless of length.
|
|
10
|
+
* :class:`OracleBlob` — bind as ``DB_TYPE_BLOB`` regardless of length.
|
|
11
|
+
* :class:`OracleJson` — bind as native JSON; defers to the C1 input handler.
|
|
12
|
+
|
|
13
|
+
The wrappers themselves perform no validation — type discipline lives at the
|
|
14
|
+
routing site so error messages can include database-context detail.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
__all__ = ("OracleBlob", "OracleClob", "OracleJson")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class OracleClob:
|
|
23
|
+
"""Mark a value to be bound as ``DB_TYPE_CLOB`` regardless of length."""
|
|
24
|
+
|
|
25
|
+
__slots__ = ("value",)
|
|
26
|
+
|
|
27
|
+
def __init__(self, value: "str | bytes") -> None:
|
|
28
|
+
self.value = value
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class OracleBlob:
|
|
32
|
+
"""Mark a value to be bound as ``DB_TYPE_BLOB`` regardless of length."""
|
|
33
|
+
|
|
34
|
+
__slots__ = ("value",)
|
|
35
|
+
|
|
36
|
+
def __init__(self, value: "bytes | str") -> None:
|
|
37
|
+
self.value = value
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class OracleJson:
|
|
41
|
+
"""Mark a value to be bound as native ``DB_TYPE_JSON`` regardless of detected version."""
|
|
42
|
+
|
|
43
|
+
__slots__ = ("value",)
|
|
44
|
+
|
|
45
|
+
def __init__(self, value: Any) -> None:
|
|
46
|
+
self.value = value
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""Oracle adapter type definitions.
|
|
2
|
+
|
|
3
|
+
This module contains type aliases and classes that are excluded from mypyc
|
|
4
|
+
compilation to avoid ABI boundary issues.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import contextlib
|
|
8
|
+
from typing import TYPE_CHECKING, Any, Protocol
|
|
9
|
+
|
|
10
|
+
import oracledb as _oracledb
|
|
11
|
+
from oracledb import (
|
|
12
|
+
DB_TYPE_BLOB,
|
|
13
|
+
DB_TYPE_CLOB,
|
|
14
|
+
DB_TYPE_JSON,
|
|
15
|
+
DB_TYPE_RAW,
|
|
16
|
+
AsyncConnection,
|
|
17
|
+
AsyncCursor,
|
|
18
|
+
Connection,
|
|
19
|
+
Cursor,
|
|
20
|
+
DatabaseError,
|
|
21
|
+
)
|
|
22
|
+
from oracledb.pool import AsyncConnectionPool, ConnectionPool
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
from collections.abc import Callable
|
|
26
|
+
from types import TracebackType
|
|
27
|
+
from typing import TypeAlias
|
|
28
|
+
|
|
29
|
+
from oracledb import DB_TYPE_VECTOR # pyright: ignore[reportUnknownVariableType]
|
|
30
|
+
|
|
31
|
+
from sqlspec.adapters.oracledb.driver import OracleAsyncDriver, OracleSyncDriver
|
|
32
|
+
from sqlspec.builder import QueryBuilder
|
|
33
|
+
from sqlspec.core import SQL, Statement, StatementConfig
|
|
34
|
+
|
|
35
|
+
OracleSyncConnection: TypeAlias = Connection
|
|
36
|
+
OracleAsyncConnection: TypeAlias = AsyncConnection
|
|
37
|
+
OracleSyncConnectionPool: TypeAlias = ConnectionPool
|
|
38
|
+
OracleAsyncConnectionPool: TypeAlias = AsyncConnectionPool
|
|
39
|
+
OracleSyncRawCursor: TypeAlias = Cursor
|
|
40
|
+
OracleAsyncRawCursor: TypeAlias = AsyncCursor
|
|
41
|
+
OracleVectorType: TypeAlias = int
|
|
42
|
+
|
|
43
|
+
if not TYPE_CHECKING:
|
|
44
|
+
try:
|
|
45
|
+
from oracledb import DB_TYPE_VECTOR
|
|
46
|
+
|
|
47
|
+
OracleVectorType = int
|
|
48
|
+
except ImportError:
|
|
49
|
+
DB_TYPE_VECTOR = None
|
|
50
|
+
OracleVectorType = int
|
|
51
|
+
|
|
52
|
+
OracleSyncConnection = Connection
|
|
53
|
+
OracleAsyncConnection = AsyncConnection
|
|
54
|
+
OracleSyncConnectionPool = ConnectionPool
|
|
55
|
+
OracleAsyncConnectionPool = AsyncConnectionPool
|
|
56
|
+
OracleSyncRawCursor = Cursor
|
|
57
|
+
OracleAsyncRawCursor = AsyncCursor
|
|
58
|
+
|
|
59
|
+
AQDequeueOptions: Any | None = getattr(_oracledb, "AQDequeueOptions", None)
|
|
60
|
+
AQMSG_VISIBLE: int | None = getattr(_oracledb, "AQMSG_VISIBLE", None)
|
|
61
|
+
AQMSG_INVISIBLE: int | None = getattr(_oracledb, "AQMSG_INVISIBLE", None)
|
|
62
|
+
AQMSG_PAYLOAD_TYPE_JSON: Any | None = getattr(_oracledb, "AQMSG_PAYLOAD_TYPE_JSON", None)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class OracleSyncCursor:
|
|
66
|
+
"""Sync context manager for Oracle cursor management."""
|
|
67
|
+
|
|
68
|
+
__slots__ = ("connection", "cursor")
|
|
69
|
+
|
|
70
|
+
def __init__(self, connection: OracleSyncConnection) -> None:
|
|
71
|
+
self.connection = connection
|
|
72
|
+
self.cursor: OracleSyncRawCursor | None = None
|
|
73
|
+
|
|
74
|
+
def __enter__(self) -> "OracleSyncRawCursor":
|
|
75
|
+
self.cursor = self.connection.cursor()
|
|
76
|
+
return self.cursor
|
|
77
|
+
|
|
78
|
+
def __exit__(self, *_: object) -> None:
|
|
79
|
+
if self.cursor is not None:
|
|
80
|
+
self.cursor.close()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class OracleAsyncCursor:
|
|
84
|
+
"""Async context manager for Oracle cursor management."""
|
|
85
|
+
|
|
86
|
+
__slots__ = ("connection", "cursor")
|
|
87
|
+
|
|
88
|
+
def __init__(self, connection: OracleAsyncConnection) -> None:
|
|
89
|
+
self.connection = connection
|
|
90
|
+
self.cursor: OracleAsyncRawCursor | None = None
|
|
91
|
+
|
|
92
|
+
async def __aenter__(self) -> "OracleAsyncRawCursor":
|
|
93
|
+
self.cursor = self.connection.cursor()
|
|
94
|
+
return self.cursor
|
|
95
|
+
|
|
96
|
+
async def __aexit__(
|
|
97
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
98
|
+
) -> None:
|
|
99
|
+
_ = (exc_type, exc_val, exc_tb) # Mark as intentionally unused
|
|
100
|
+
if self.cursor is not None:
|
|
101
|
+
with contextlib.suppress(Exception):
|
|
102
|
+
# Oracle async cursors have a synchronous close method
|
|
103
|
+
# but we need to ensure proper cleanup in the event loop context
|
|
104
|
+
self.cursor.close()
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class OraclePipelineDriver(Protocol):
|
|
108
|
+
"""Protocol for Oracle pipeline driver methods used in stack execution."""
|
|
109
|
+
|
|
110
|
+
statement_config: "StatementConfig"
|
|
111
|
+
driver_features: "dict[str, Any]"
|
|
112
|
+
|
|
113
|
+
def prepare_statement(
|
|
114
|
+
self,
|
|
115
|
+
statement: "str | Statement | QueryBuilder",
|
|
116
|
+
parameters: "tuple[Any, ...] | dict[str, Any] | None",
|
|
117
|
+
*,
|
|
118
|
+
statement_config: "StatementConfig | None" = None,
|
|
119
|
+
kwargs: "dict[str, Any] | None" = None,
|
|
120
|
+
) -> "SQL": ...
|
|
121
|
+
|
|
122
|
+
def _get_compiled_sql(self, statement: "SQL", statement_config: "StatementConfig") -> "tuple[str, Any]": ...
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class OracleSyncSessionContext:
|
|
126
|
+
"""Sync context manager for Oracle sessions.
|
|
127
|
+
|
|
128
|
+
This class is intentionally excluded from mypyc compilation to avoid ABI
|
|
129
|
+
boundary issues. It receives callables from uncompiled config classes and
|
|
130
|
+
instantiates compiled Driver objects, acting as a bridge between compiled
|
|
131
|
+
and uncompiled code.
|
|
132
|
+
|
|
133
|
+
Uses callable-based connection management to decouple from config implementation.
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
__slots__ = (
|
|
137
|
+
"_acquire_connection",
|
|
138
|
+
"_connection",
|
|
139
|
+
"_driver",
|
|
140
|
+
"_driver_features",
|
|
141
|
+
"_prepare_driver",
|
|
142
|
+
"_release_connection",
|
|
143
|
+
"_statement_config",
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
def __init__(
|
|
147
|
+
self,
|
|
148
|
+
acquire_connection: "Callable[[], Any]",
|
|
149
|
+
release_connection: "Callable[[Any], Any]",
|
|
150
|
+
statement_config: "StatementConfig",
|
|
151
|
+
driver_features: "dict[str, Any]",
|
|
152
|
+
prepare_driver: "Callable[[OracleSyncDriver], OracleSyncDriver]",
|
|
153
|
+
) -> None:
|
|
154
|
+
self._acquire_connection = acquire_connection
|
|
155
|
+
self._release_connection = release_connection
|
|
156
|
+
self._statement_config = statement_config
|
|
157
|
+
self._driver_features = driver_features
|
|
158
|
+
self._prepare_driver = prepare_driver
|
|
159
|
+
self._connection: Any = None
|
|
160
|
+
self._driver: OracleSyncDriver | None = None
|
|
161
|
+
|
|
162
|
+
def __enter__(self) -> "OracleSyncDriver":
|
|
163
|
+
from sqlspec.adapters.oracledb.driver import OracleSyncDriver
|
|
164
|
+
|
|
165
|
+
self._connection = self._acquire_connection()
|
|
166
|
+
self._driver = OracleSyncDriver(
|
|
167
|
+
connection=self._connection, statement_config=self._statement_config, driver_features=self._driver_features
|
|
168
|
+
)
|
|
169
|
+
return self._prepare_driver(self._driver)
|
|
170
|
+
|
|
171
|
+
def __exit__(
|
|
172
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
173
|
+
) -> "bool | None":
|
|
174
|
+
if self._connection is not None:
|
|
175
|
+
self._release_connection(self._connection)
|
|
176
|
+
self._connection = None
|
|
177
|
+
return None
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class OracleAsyncSessionContext:
|
|
181
|
+
"""Async context manager for Oracle sessions.
|
|
182
|
+
|
|
183
|
+
This class is intentionally excluded from mypyc compilation to avoid ABI
|
|
184
|
+
boundary issues. It receives callables from uncompiled config classes and
|
|
185
|
+
instantiates compiled Driver objects, acting as a bridge between compiled
|
|
186
|
+
and uncompiled code.
|
|
187
|
+
|
|
188
|
+
Uses callable-based connection management to decouple from config implementation.
|
|
189
|
+
"""
|
|
190
|
+
|
|
191
|
+
__slots__ = (
|
|
192
|
+
"_acquire_connection",
|
|
193
|
+
"_connection",
|
|
194
|
+
"_driver",
|
|
195
|
+
"_driver_features",
|
|
196
|
+
"_prepare_driver",
|
|
197
|
+
"_release_connection",
|
|
198
|
+
"_statement_config",
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
def __init__(
|
|
202
|
+
self,
|
|
203
|
+
acquire_connection: "Callable[[], Any]",
|
|
204
|
+
release_connection: "Callable[[Any], Any]",
|
|
205
|
+
statement_config: "StatementConfig",
|
|
206
|
+
driver_features: "dict[str, Any]",
|
|
207
|
+
prepare_driver: "Callable[[OracleAsyncDriver], OracleAsyncDriver]",
|
|
208
|
+
) -> None:
|
|
209
|
+
self._acquire_connection = acquire_connection
|
|
210
|
+
self._release_connection = release_connection
|
|
211
|
+
self._statement_config = statement_config
|
|
212
|
+
self._driver_features = driver_features
|
|
213
|
+
self._prepare_driver = prepare_driver
|
|
214
|
+
self._connection: Any = None
|
|
215
|
+
self._driver: OracleAsyncDriver | None = None
|
|
216
|
+
|
|
217
|
+
async def __aenter__(self) -> "OracleAsyncDriver":
|
|
218
|
+
from sqlspec.adapters.oracledb.driver import OracleAsyncDriver
|
|
219
|
+
|
|
220
|
+
self._connection = await self._acquire_connection()
|
|
221
|
+
self._driver = OracleAsyncDriver(
|
|
222
|
+
connection=self._connection, statement_config=self._statement_config, driver_features=self._driver_features
|
|
223
|
+
)
|
|
224
|
+
return self._prepare_driver(self._driver)
|
|
225
|
+
|
|
226
|
+
async def __aexit__(
|
|
227
|
+
self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: "TracebackType | None"
|
|
228
|
+
) -> "bool | None":
|
|
229
|
+
if self._connection is not None:
|
|
230
|
+
await self._release_connection(self._connection)
|
|
231
|
+
self._connection = None
|
|
232
|
+
return None
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
__all__ = (
|
|
236
|
+
"AQMSG_INVISIBLE",
|
|
237
|
+
"AQMSG_PAYLOAD_TYPE_JSON",
|
|
238
|
+
"AQMSG_VISIBLE",
|
|
239
|
+
"DB_TYPE_BLOB",
|
|
240
|
+
"DB_TYPE_CLOB",
|
|
241
|
+
"DB_TYPE_JSON",
|
|
242
|
+
"DB_TYPE_RAW",
|
|
243
|
+
"DB_TYPE_VECTOR",
|
|
244
|
+
"AQDequeueOptions",
|
|
245
|
+
"DatabaseError",
|
|
246
|
+
"OracleAsyncConnection",
|
|
247
|
+
"OracleAsyncConnectionPool",
|
|
248
|
+
"OracleAsyncCursor",
|
|
249
|
+
"OracleAsyncRawCursor",
|
|
250
|
+
"OracleAsyncSessionContext",
|
|
251
|
+
"OraclePipelineDriver",
|
|
252
|
+
"OracleSyncConnection",
|
|
253
|
+
"OracleSyncConnectionPool",
|
|
254
|
+
"OracleSyncCursor",
|
|
255
|
+
"OracleSyncRawCursor",
|
|
256
|
+
"OracleSyncSessionContext",
|
|
257
|
+
"OracleVectorType",
|
|
258
|
+
)
|
|
Binary file
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""Oracle UUID type handlers for RAW(16) binary storage.
|
|
2
|
+
|
|
3
|
+
Provides automatic conversion between Python UUID objects and Oracle RAW(16)
|
|
4
|
+
via connection type handlers. Uses stdlib uuid (no external dependencies).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import uuid
|
|
8
|
+
from typing import TYPE_CHECKING, Any
|
|
9
|
+
|
|
10
|
+
from sqlspec.adapters.oracledb._typing import DB_TYPE_RAW
|
|
11
|
+
from sqlspec.utils.logging import get_logger
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from oracledb import AsyncConnection, AsyncCursor, Connection, Cursor
|
|
15
|
+
|
|
16
|
+
__all__ = (
|
|
17
|
+
"register_uuid_handlers",
|
|
18
|
+
"uuid_converter_in",
|
|
19
|
+
"uuid_converter_out",
|
|
20
|
+
"uuid_input_type_handler",
|
|
21
|
+
"uuid_output_type_handler",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
logger = get_logger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
UUID_BINARY_SIZE = 16
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def uuid_converter_in(value: uuid.UUID) -> bytes:
|
|
32
|
+
"""Convert Python UUID to 16-byte binary for Oracle RAW(16).
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
value: Python UUID object to convert.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
16-byte binary representation in big-endian format (RFC 4122).
|
|
39
|
+
"""
|
|
40
|
+
return value.bytes
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def uuid_converter_out(value: bytes | None) -> "uuid.UUID | bytes | None":
|
|
44
|
+
"""Convert 16-byte binary from Oracle RAW(16) to Python UUID.
|
|
45
|
+
|
|
46
|
+
Falls back to bytes if value is not valid UUID format.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
value: 16-byte binary from Oracle RAW(16) column, or None.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
Python UUID object if valid, original bytes if invalid, None if NULL.
|
|
53
|
+
"""
|
|
54
|
+
if value is None:
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
if len(value) != UUID_BINARY_SIZE:
|
|
58
|
+
return value
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
return uuid.UUID(bytes=value)
|
|
62
|
+
except (ValueError, TypeError):
|
|
63
|
+
logger.debug("RAW(16) value is not valid UUID format, returning as bytes", extra={"value_length": len(value)})
|
|
64
|
+
return value
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _input_type_handler(cursor: "Cursor | AsyncCursor", value: Any, arraysize: int) -> Any:
|
|
68
|
+
"""Oracle input type handler for UUID objects.
|
|
69
|
+
|
|
70
|
+
Detects Python UUID objects and converts them to RAW(16) binary format.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
cursor: Oracle cursor (sync or async).
|
|
74
|
+
value: Value being inserted.
|
|
75
|
+
arraysize: Array size for the cursor variable.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Cursor variable with UUID converter if value is UUID, None otherwise.
|
|
79
|
+
"""
|
|
80
|
+
if isinstance(value, uuid.UUID):
|
|
81
|
+
return cursor.var(DB_TYPE_RAW, arraysize=arraysize, inconverter=uuid_converter_in)
|
|
82
|
+
return None
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _output_type_handler(cursor: "Cursor | AsyncCursor", metadata: Any) -> Any:
|
|
86
|
+
"""Oracle output type handler for RAW(16) columns.
|
|
87
|
+
|
|
88
|
+
Detects RAW(16) columns and converts them to Python UUID objects.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
cursor: Oracle cursor (sync or async).
|
|
92
|
+
metadata: Column metadata tuple (name, type_code, display_size, internal_size, precision, scale, null_ok).
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Cursor variable with UUID converter if column is RAW(16), None otherwise.
|
|
96
|
+
"""
|
|
97
|
+
_name, type_code, _display_size, internal_size, _precision, _scale, _null_ok = metadata
|
|
98
|
+
|
|
99
|
+
if type_code is DB_TYPE_RAW and internal_size == UUID_BINARY_SIZE:
|
|
100
|
+
return cursor.var(type_code, arraysize=cursor.arraysize, outconverter=uuid_converter_out)
|
|
101
|
+
return None
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def uuid_input_type_handler(cursor: "Cursor | AsyncCursor", value: Any, arraysize: int) -> Any:
|
|
105
|
+
"""Public input type handler for UUID values."""
|
|
106
|
+
return _input_type_handler(cursor, value, arraysize)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def uuid_output_type_handler(cursor: "Cursor | AsyncCursor", metadata: Any) -> Any:
|
|
110
|
+
"""Public output type handler for RAW(16) UUID values."""
|
|
111
|
+
return _output_type_handler(cursor, metadata)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def register_uuid_handlers(connection: "Connection | AsyncConnection") -> None:
|
|
115
|
+
"""Register UUID type handlers with chaining support.
|
|
116
|
+
|
|
117
|
+
Chains to existing type handlers (e.g., NumPy vectors) to avoid conflicts.
|
|
118
|
+
Works for both sync and async connections.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
connection: Oracle connection (sync or async).
|
|
122
|
+
"""
|
|
123
|
+
try:
|
|
124
|
+
existing_input = connection.inputtypehandler
|
|
125
|
+
except AttributeError:
|
|
126
|
+
existing_input = None
|
|
127
|
+
try:
|
|
128
|
+
existing_output = connection.outputtypehandler
|
|
129
|
+
except AttributeError:
|
|
130
|
+
existing_output = None
|
|
131
|
+
|
|
132
|
+
connection.inputtypehandler = _UuidInputHandler(existing_input)
|
|
133
|
+
connection.outputtypehandler = _UuidOutputHandler(existing_output)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class _UuidInputHandler:
|
|
137
|
+
__slots__ = ("_fallback",)
|
|
138
|
+
|
|
139
|
+
def __init__(self, fallback: "Any | None") -> None:
|
|
140
|
+
self._fallback = fallback
|
|
141
|
+
|
|
142
|
+
def __call__(self, cursor: "Cursor | AsyncCursor", value: Any, arraysize: int) -> Any:
|
|
143
|
+
result = _input_type_handler(cursor, value, arraysize)
|
|
144
|
+
if result is not None:
|
|
145
|
+
return result
|
|
146
|
+
if self._fallback is not None:
|
|
147
|
+
return self._fallback(cursor, value, arraysize)
|
|
148
|
+
return None
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class _UuidOutputHandler:
|
|
152
|
+
__slots__ = ("_fallback",)
|
|
153
|
+
|
|
154
|
+
def __init__(self, fallback: "Any | None") -> None:
|
|
155
|
+
self._fallback = fallback
|
|
156
|
+
|
|
157
|
+
def __call__(self, cursor: "Cursor | AsyncCursor", metadata: Any) -> Any:
|
|
158
|
+
result = _output_type_handler(cursor, metadata)
|
|
159
|
+
if result is not None:
|
|
160
|
+
return result
|
|
161
|
+
if self._fallback is not None:
|
|
162
|
+
return self._fallback(cursor, metadata)
|
|
163
|
+
return None
|
|
Binary file
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"""Oracle vector type handlers for the DB_TYPE_VECTOR data type.
|
|
2
|
+
|
|
3
|
+
Provides automatic conversion between Python sequence-of-numbers
|
|
4
|
+
(``numpy.ndarray``, ``array.array``, ``list``, ``tuple``) and Oracle VECTOR
|
|
5
|
+
columns. Requires Oracle Database 23ai or higher.
|
|
6
|
+
|
|
7
|
+
Public symbols keep the historical ``numpy_*`` prefix for backwards-compat with
|
|
8
|
+
sqlspec ``__all__`` consumers; the user-facing rename to ``vector_*`` is tracked
|
|
9
|
+
as a follow-up.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import array
|
|
13
|
+
from typing import TYPE_CHECKING, Any
|
|
14
|
+
|
|
15
|
+
from sqlspec.adapters.oracledb._typing import DB_TYPE_VECTOR
|
|
16
|
+
from sqlspec.typing import NUMPY_INSTALLED
|
|
17
|
+
from sqlspec.utils.logging import get_logger
|
|
18
|
+
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
from oracledb import AsyncConnection, AsyncCursor, Connection, Cursor
|
|
21
|
+
|
|
22
|
+
__all__ = (
|
|
23
|
+
"DTYPE_TO_ARRAY_CODE",
|
|
24
|
+
"numpy_converter_in",
|
|
25
|
+
"numpy_converter_out",
|
|
26
|
+
"numpy_input_type_handler",
|
|
27
|
+
"numpy_output_type_handler",
|
|
28
|
+
"register_numpy_handlers",
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
logger = get_logger(__name__)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
_TYPECODE_FLOAT64 = "d"
|
|
36
|
+
_TYPECODE_FLOAT32 = "f"
|
|
37
|
+
_TYPECODE_FLOAT16 = "e"
|
|
38
|
+
_TYPECODE_UINT8 = "B"
|
|
39
|
+
_TYPECODE_INT8 = "b"
|
|
40
|
+
_TYPECODE_INT16 = "h"
|
|
41
|
+
_TYPECODE_INT32 = "i"
|
|
42
|
+
|
|
43
|
+
_INT8_MIN = -128
|
|
44
|
+
_INT8_MAX = 127
|
|
45
|
+
|
|
46
|
+
_VECTOR_RETURN_NUMPY = "numpy"
|
|
47
|
+
_VECTOR_RETURN_LIST = "list"
|
|
48
|
+
_VECTOR_RETURN_ARRAY = "array"
|
|
49
|
+
_VECTOR_RETURN_FORMATS = frozenset({_VECTOR_RETURN_NUMPY, _VECTOR_RETURN_LIST, _VECTOR_RETURN_ARRAY})
|
|
50
|
+
|
|
51
|
+
DTYPE_TO_ARRAY_CODE: "dict[str, str]" = {
|
|
52
|
+
"float64": _TYPECODE_FLOAT64,
|
|
53
|
+
"float32": _TYPECODE_FLOAT32,
|
|
54
|
+
"uint8": _TYPECODE_UINT8,
|
|
55
|
+
"int8": _TYPECODE_INT8,
|
|
56
|
+
"int16": _TYPECODE_INT16,
|
|
57
|
+
"int32": _TYPECODE_INT32,
|
|
58
|
+
}
|
|
59
|
+
try:
|
|
60
|
+
array.array(_TYPECODE_FLOAT16)
|
|
61
|
+
except ValueError:
|
|
62
|
+
pass
|
|
63
|
+
else:
|
|
64
|
+
DTYPE_TO_ARRAY_CODE["float16"] = _TYPECODE_FLOAT16
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def numpy_converter_in(value: Any) -> "array.array[Any]":
|
|
68
|
+
"""Convert NumPy array to Oracle array for VECTOR insertion.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
value: NumPy ndarray to convert.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
Python array.array compatible with Oracle VECTOR type.
|
|
75
|
+
|
|
76
|
+
Raises:
|
|
77
|
+
ImportError: If NumPy is not installed.
|
|
78
|
+
TypeError: If NumPy dtype is not supported for Oracle VECTOR.
|
|
79
|
+
"""
|
|
80
|
+
if not NUMPY_INSTALLED:
|
|
81
|
+
msg = "NumPy is not installed - cannot convert vectors"
|
|
82
|
+
raise ImportError(msg)
|
|
83
|
+
|
|
84
|
+
dtype_name = value.dtype.name
|
|
85
|
+
array_code = DTYPE_TO_ARRAY_CODE.get(dtype_name)
|
|
86
|
+
|
|
87
|
+
if not array_code:
|
|
88
|
+
supported = ", ".join(DTYPE_TO_ARRAY_CODE.keys())
|
|
89
|
+
msg = f"Unsupported NumPy dtype for Oracle VECTOR: {dtype_name}. Supported: {supported}"
|
|
90
|
+
raise TypeError(msg)
|
|
91
|
+
|
|
92
|
+
return array.array(array_code, value)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def numpy_converter_out(value: "array.array[Any]") -> Any:
|
|
96
|
+
"""Convert Oracle array to NumPy array for VECTOR retrieval.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
value: Oracle array.array from VECTOR column.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
NumPy ndarray with appropriate dtype, or original value if NumPy not installed.
|
|
103
|
+
"""
|
|
104
|
+
if not NUMPY_INSTALLED:
|
|
105
|
+
return value
|
|
106
|
+
|
|
107
|
+
import numpy as np
|
|
108
|
+
|
|
109
|
+
return np.array(value, copy=True, dtype=value.typecode)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _is_vector_payload(value: Any) -> bool:
|
|
113
|
+
"""Return True if the value should be claimed by the vector input handler.
|
|
114
|
+
|
|
115
|
+
Mirrors the C1 ``_is_json_payload`` predicate but inverted: claims sequences
|
|
116
|
+
of numbers (vector embeddings); rejects ``dict`` / ``list[dict]`` which the
|
|
117
|
+
JSON handler owns. ``bool`` is excluded explicitly because it is a subclass
|
|
118
|
+
of ``int`` but is owned by the JSON path.
|
|
119
|
+
"""
|
|
120
|
+
if isinstance(value, array.array):
|
|
121
|
+
return True
|
|
122
|
+
if NUMPY_INSTALLED:
|
|
123
|
+
import numpy as np
|
|
124
|
+
|
|
125
|
+
if isinstance(value, np.ndarray):
|
|
126
|
+
return True
|
|
127
|
+
if isinstance(value, (list, tuple)) and value:
|
|
128
|
+
first = value[0]
|
|
129
|
+
if isinstance(first, bool):
|
|
130
|
+
return False
|
|
131
|
+
return isinstance(first, (int, float))
|
|
132
|
+
return False
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _pack_python_sequence(value: "list[Any] | tuple[Any, ...]") -> "array.array[Any]":
|
|
136
|
+
"""Pack a Python sequence into an ``array.array`` for VECTOR binding.
|
|
137
|
+
|
|
138
|
+
Integer sequences entirely within ``[-128, 127]`` use the int8 typecode for
|
|
139
|
+
a cheaper bind; everything else falls back to float32 (the 23ai default and
|
|
140
|
+
the most common LLM embedding dtype).
|
|
141
|
+
"""
|
|
142
|
+
if all(isinstance(v, int) and not isinstance(v, bool) and _INT8_MIN <= v <= _INT8_MAX for v in value):
|
|
143
|
+
return array.array(_TYPECODE_INT8, value)
|
|
144
|
+
return array.array(_TYPECODE_FLOAT32, [float(v) for v in value])
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _input_type_handler(cursor: "Cursor | AsyncCursor", value: Any, arraysize: int) -> Any:
|
|
148
|
+
"""Oracle input type handler for vector payloads.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
cursor: Oracle cursor (sync or async).
|
|
152
|
+
value: Value being inserted.
|
|
153
|
+
arraysize: Array size for the cursor variable.
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
Cursor variable for VECTOR binding when ``value`` is a vector payload,
|
|
157
|
+
otherwise ``None`` so the next handler in the chain can claim it.
|
|
158
|
+
"""
|
|
159
|
+
if not _is_vector_payload(value):
|
|
160
|
+
return None
|
|
161
|
+
|
|
162
|
+
if NUMPY_INSTALLED:
|
|
163
|
+
import numpy as np
|
|
164
|
+
|
|
165
|
+
if isinstance(value, np.ndarray):
|
|
166
|
+
return cursor.var(DB_TYPE_VECTOR, arraysize=arraysize, inconverter=numpy_converter_in)
|
|
167
|
+
|
|
168
|
+
if isinstance(value, array.array):
|
|
169
|
+
return cursor.var(DB_TYPE_VECTOR, arraysize=arraysize)
|
|
170
|
+
|
|
171
|
+
packed = _pack_python_sequence(value)
|
|
172
|
+
return cursor.var(DB_TYPE_VECTOR, arraysize=arraysize, inconverter=lambda _v: packed)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _output_type_handler(cursor: "Cursor | AsyncCursor", metadata: Any) -> Any:
|
|
176
|
+
"""Oracle output type handler for VECTOR columns.
|
|
177
|
+
|
|
178
|
+
Reads ``connection._sqlspec_vector_return_format`` (set by the session
|
|
179
|
+
callback in ``config._init_connection``) to dispatch to the requested
|
|
180
|
+
return type. Falls back to ``"numpy"`` when NumPy is installed and
|
|
181
|
+
``"list"`` otherwise so consumers without the connection-level setting
|
|
182
|
+
still get sensible behavior.
|
|
183
|
+
"""
|
|
184
|
+
if metadata.type_code is not DB_TYPE_VECTOR:
|
|
185
|
+
return None
|
|
186
|
+
|
|
187
|
+
fmt = getattr(cursor.connection, "_sqlspec_vector_return_format", None)
|
|
188
|
+
if fmt is None:
|
|
189
|
+
fmt = _VECTOR_RETURN_NUMPY if NUMPY_INSTALLED else _VECTOR_RETURN_LIST
|
|
190
|
+
|
|
191
|
+
if fmt == _VECTOR_RETURN_NUMPY:
|
|
192
|
+
if not NUMPY_INSTALLED:
|
|
193
|
+
msg = (
|
|
194
|
+
"vector_return_format='numpy' requires numpy; install with "
|
|
195
|
+
"`pip install sqlspec[oracle,numpy]` or set vector_return_format='list'."
|
|
196
|
+
)
|
|
197
|
+
raise RuntimeError(msg)
|
|
198
|
+
return cursor.var(metadata.type_code, arraysize=cursor.arraysize, outconverter=numpy_converter_out)
|
|
199
|
+
if fmt == _VECTOR_RETURN_LIST:
|
|
200
|
+
return cursor.var(metadata.type_code, arraysize=cursor.arraysize, outconverter=list)
|
|
201
|
+
if fmt == _VECTOR_RETURN_ARRAY:
|
|
202
|
+
return None
|
|
203
|
+
|
|
204
|
+
msg = f"Invalid vector_return_format: {fmt!r}; expected one of {sorted(_VECTOR_RETURN_FORMATS)}"
|
|
205
|
+
raise ValueError(msg)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def numpy_input_type_handler(cursor: "Cursor | AsyncCursor", value: Any, arraysize: int) -> Any:
|
|
209
|
+
"""Public input type handler for vector payloads."""
|
|
210
|
+
return _input_type_handler(cursor, value, arraysize)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def numpy_output_type_handler(cursor: "Cursor | AsyncCursor", metadata: Any) -> Any:
|
|
214
|
+
"""Public output type handler for VECTOR columns."""
|
|
215
|
+
return _output_type_handler(cursor, metadata)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def register_numpy_handlers(connection: "Connection | AsyncConnection") -> None:
|
|
219
|
+
"""Register vector type handlers on an Oracle connection.
|
|
220
|
+
|
|
221
|
+
Enables automatic conversion between Python sequence types and Oracle
|
|
222
|
+
VECTOR columns. Works for both sync and async connections.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
connection: Oracle connection (sync or async).
|
|
226
|
+
"""
|
|
227
|
+
connection.inputtypehandler = numpy_input_type_handler
|
|
228
|
+
connection.outputtypehandler = numpy_output_type_handler
|