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,361 @@
|
|
|
1
|
+
"""Base store classes for ADK artifact metadata backend (sync and async).
|
|
2
|
+
|
|
3
|
+
These abstract base classes define the database operations needed to manage
|
|
4
|
+
artifact version metadata. Content storage is handled separately by
|
|
5
|
+
``sqlspec/storage/`` backends; these stores only manage the relational
|
|
6
|
+
metadata rows.
|
|
7
|
+
|
|
8
|
+
Concrete subclasses implement the abstract methods with dialect-specific SQL.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
import re
|
|
13
|
+
from abc import ABC, abstractmethod
|
|
14
|
+
from typing import TYPE_CHECKING, Any, Final, Generic, TypeVar
|
|
15
|
+
|
|
16
|
+
from sqlspec.extensions.adk._config_utils import _get_adk_artifact_store_config, _get_adk_config_from_extension
|
|
17
|
+
from sqlspec.observability import resolve_db_system
|
|
18
|
+
from sqlspec.utils.logging import get_logger, log_with_context
|
|
19
|
+
|
|
20
|
+
if TYPE_CHECKING:
|
|
21
|
+
from sqlspec.config import DatabaseConfigProtocol
|
|
22
|
+
from sqlspec.extensions.adk.artifact._types import ArtifactRecord
|
|
23
|
+
|
|
24
|
+
ConfigT = TypeVar("ConfigT", bound="DatabaseConfigProtocol[Any, Any, Any]")
|
|
25
|
+
|
|
26
|
+
logger = get_logger("sqlspec.extensions.adk.artifact.store")
|
|
27
|
+
|
|
28
|
+
__all__ = ("BaseAsyncADKArtifactStore", "BaseSyncADKArtifactStore")
|
|
29
|
+
|
|
30
|
+
VALID_TABLE_NAME_PATTERN: Final = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")
|
|
31
|
+
MAX_TABLE_NAME_LENGTH: Final = 63
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _validate_table_name(table_name: str) -> None:
|
|
35
|
+
"""Validate table name for SQL safety.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
table_name: Table name to validate.
|
|
39
|
+
|
|
40
|
+
Raises:
|
|
41
|
+
ValueError: If table name is invalid.
|
|
42
|
+
"""
|
|
43
|
+
if not table_name:
|
|
44
|
+
msg = "Table name cannot be empty"
|
|
45
|
+
raise ValueError(msg)
|
|
46
|
+
|
|
47
|
+
if len(table_name) > MAX_TABLE_NAME_LENGTH:
|
|
48
|
+
msg = f"Table name too long: {len(table_name)} chars (max {MAX_TABLE_NAME_LENGTH})"
|
|
49
|
+
raise ValueError(msg)
|
|
50
|
+
|
|
51
|
+
if not VALID_TABLE_NAME_PATTERN.match(table_name):
|
|
52
|
+
msg = (
|
|
53
|
+
f"Invalid table name: {table_name!r}. "
|
|
54
|
+
"Must start with letter/underscore and contain only alphanumeric characters and underscores"
|
|
55
|
+
)
|
|
56
|
+
raise ValueError(msg)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class BaseAsyncADKArtifactStore(ABC, Generic[ConfigT]):
|
|
60
|
+
"""Base class for async SQLSpec-backed ADK artifact metadata stores.
|
|
61
|
+
|
|
62
|
+
Manages artifact version metadata in a SQL table. Content bytes are
|
|
63
|
+
stored externally via ``sqlspec/storage/`` backends and referenced
|
|
64
|
+
by canonical URI in each metadata row.
|
|
65
|
+
|
|
66
|
+
Subclasses must implement dialect-specific SQL queries.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
config: SQLSpec database configuration with extension_config["adk"] settings.
|
|
70
|
+
|
|
71
|
+
Notes:
|
|
72
|
+
Configuration is read from config.extension_config["adk"]:
|
|
73
|
+
- artifact_table: Artifact versions table name (default: "adk_artifact_versions")
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
__slots__ = ("_artifact_table", "_config")
|
|
77
|
+
|
|
78
|
+
def __init__(self, config: ConfigT) -> None:
|
|
79
|
+
"""Initialize the async ADK artifact store.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
config: SQLSpec database configuration.
|
|
83
|
+
"""
|
|
84
|
+
self._config = config
|
|
85
|
+
store_config = _get_adk_artifact_store_config(self._config)
|
|
86
|
+
self._artifact_table: str = store_config["artifact_table"]
|
|
87
|
+
_validate_table_name(self._artifact_table)
|
|
88
|
+
|
|
89
|
+
def _get_adk_config(self) -> "dict[str, Any]":
|
|
90
|
+
"""Extract ADK configuration from extension_config.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
Dict with ADK configuration values.
|
|
94
|
+
"""
|
|
95
|
+
return _get_adk_config_from_extension(self._config)
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def config(self) -> ConfigT:
|
|
99
|
+
"""Return the database configuration."""
|
|
100
|
+
return self._config
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def artifact_table(self) -> str:
|
|
104
|
+
"""Return the artifact versions table name."""
|
|
105
|
+
return self._artifact_table
|
|
106
|
+
|
|
107
|
+
@abstractmethod
|
|
108
|
+
async def insert_artifact(self, record: "ArtifactRecord") -> None:
|
|
109
|
+
"""Insert an artifact version metadata row.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
record: Artifact metadata record to insert.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
@abstractmethod
|
|
116
|
+
async def get_artifact(
|
|
117
|
+
self, app_name: str, user_id: str, filename: str, session_id: "str | None" = None, version: "int | None" = None
|
|
118
|
+
) -> "ArtifactRecord | None":
|
|
119
|
+
"""Get a specific artifact version's metadata.
|
|
120
|
+
|
|
121
|
+
When ``version`` is None, returns the latest version.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
app_name: Application name.
|
|
125
|
+
user_id: User identifier.
|
|
126
|
+
filename: Artifact filename.
|
|
127
|
+
session_id: Session identifier (None for user-scoped).
|
|
128
|
+
version: Specific version number, or None for latest.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
Artifact record if found, None otherwise.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
@abstractmethod
|
|
135
|
+
async def list_artifact_keys(self, app_name: str, user_id: str, session_id: "str | None" = None) -> "list[str]":
|
|
136
|
+
"""List distinct artifact filenames.
|
|
137
|
+
|
|
138
|
+
When ``session_id`` is provided, returns filenames from both
|
|
139
|
+
session-scoped and user-scoped artifacts. When None, returns
|
|
140
|
+
only user-scoped artifact filenames.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
app_name: Application name.
|
|
144
|
+
user_id: User identifier.
|
|
145
|
+
session_id: Session identifier (None for user-scoped only).
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
List of distinct artifact filenames.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
@abstractmethod
|
|
152
|
+
async def list_artifact_versions(
|
|
153
|
+
self, app_name: str, user_id: str, filename: str, session_id: "str | None" = None
|
|
154
|
+
) -> "list[ArtifactRecord]":
|
|
155
|
+
"""List all version records for an artifact, ordered by version ascending.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
app_name: Application name.
|
|
159
|
+
user_id: User identifier.
|
|
160
|
+
filename: Artifact filename.
|
|
161
|
+
session_id: Session identifier (None for user-scoped).
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
List of artifact records ordered by version ascending.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
@abstractmethod
|
|
168
|
+
async def delete_artifact(
|
|
169
|
+
self, app_name: str, user_id: str, filename: str, session_id: "str | None" = None
|
|
170
|
+
) -> "list[ArtifactRecord]":
|
|
171
|
+
"""Delete all version records for an artifact and return them.
|
|
172
|
+
|
|
173
|
+
The caller uses the returned records to clean up content from
|
|
174
|
+
object storage. Metadata is deleted first (fail-fast); content
|
|
175
|
+
cleanup is best-effort.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
app_name: Application name.
|
|
179
|
+
user_id: User identifier.
|
|
180
|
+
filename: Artifact filename.
|
|
181
|
+
session_id: Session identifier (None for user-scoped).
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
List of deleted artifact records (needed for content cleanup).
|
|
185
|
+
"""
|
|
186
|
+
|
|
187
|
+
@abstractmethod
|
|
188
|
+
async def get_next_version(
|
|
189
|
+
self, app_name: str, user_id: str, filename: str, session_id: "str | None" = None
|
|
190
|
+
) -> int:
|
|
191
|
+
"""Get the next version number for an artifact.
|
|
192
|
+
|
|
193
|
+
Returns 0 if no versions exist (first version), otherwise
|
|
194
|
+
``max(version) + 1``.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
app_name: Application name.
|
|
198
|
+
user_id: User identifier.
|
|
199
|
+
filename: Artifact filename.
|
|
200
|
+
session_id: Session identifier (None for user-scoped).
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
Next version number (0-based).
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
@abstractmethod
|
|
207
|
+
async def create_table(self) -> None:
|
|
208
|
+
"""Create the artifact versions table if it does not exist."""
|
|
209
|
+
|
|
210
|
+
async def ensure_table(self) -> None:
|
|
211
|
+
"""Create the artifact table and emit a standardized log entry."""
|
|
212
|
+
await self.create_table()
|
|
213
|
+
log_with_context(
|
|
214
|
+
logger,
|
|
215
|
+
logging.DEBUG,
|
|
216
|
+
"adk.artifact.table.ready",
|
|
217
|
+
db_system=resolve_db_system(type(self).__name__),
|
|
218
|
+
artifact_table=self._artifact_table,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class BaseSyncADKArtifactStore(ABC, Generic[ConfigT]):
|
|
223
|
+
"""Base class for sync SQLSpec-backed ADK artifact metadata stores.
|
|
224
|
+
|
|
225
|
+
Synchronous counterpart of :class:`BaseAsyncADKArtifactStore`.
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
config: SQLSpec database configuration with extension_config["adk"] settings.
|
|
229
|
+
"""
|
|
230
|
+
|
|
231
|
+
__slots__ = ("_artifact_table", "_config")
|
|
232
|
+
|
|
233
|
+
def __init__(self, config: ConfigT) -> None:
|
|
234
|
+
"""Initialize the sync ADK artifact store.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
config: SQLSpec database configuration.
|
|
238
|
+
"""
|
|
239
|
+
self._config = config
|
|
240
|
+
store_config = _get_adk_artifact_store_config(self._config)
|
|
241
|
+
self._artifact_table: str = store_config["artifact_table"]
|
|
242
|
+
_validate_table_name(self._artifact_table)
|
|
243
|
+
|
|
244
|
+
def _get_adk_config(self) -> "dict[str, Any]":
|
|
245
|
+
"""Extract ADK configuration from extension_config.
|
|
246
|
+
|
|
247
|
+
Returns:
|
|
248
|
+
Dict with ADK configuration values.
|
|
249
|
+
"""
|
|
250
|
+
return _get_adk_config_from_extension(self._config)
|
|
251
|
+
|
|
252
|
+
@property
|
|
253
|
+
def config(self) -> ConfigT:
|
|
254
|
+
"""Return the database configuration."""
|
|
255
|
+
return self._config
|
|
256
|
+
|
|
257
|
+
@property
|
|
258
|
+
def artifact_table(self) -> str:
|
|
259
|
+
"""Return the artifact versions table name."""
|
|
260
|
+
return self._artifact_table
|
|
261
|
+
|
|
262
|
+
@abstractmethod
|
|
263
|
+
def insert_artifact(self, record: "ArtifactRecord") -> None:
|
|
264
|
+
"""Insert an artifact version metadata row.
|
|
265
|
+
|
|
266
|
+
Args:
|
|
267
|
+
record: Artifact metadata record to insert.
|
|
268
|
+
"""
|
|
269
|
+
|
|
270
|
+
@abstractmethod
|
|
271
|
+
def get_artifact(
|
|
272
|
+
self, app_name: str, user_id: str, filename: str, session_id: "str | None" = None, version: "int | None" = None
|
|
273
|
+
) -> "ArtifactRecord | None":
|
|
274
|
+
"""Get a specific artifact version's metadata.
|
|
275
|
+
|
|
276
|
+
When ``version`` is None, returns the latest version.
|
|
277
|
+
|
|
278
|
+
Args:
|
|
279
|
+
app_name: Application name.
|
|
280
|
+
user_id: User identifier.
|
|
281
|
+
filename: Artifact filename.
|
|
282
|
+
session_id: Session identifier (None for user-scoped).
|
|
283
|
+
version: Specific version number, or None for latest.
|
|
284
|
+
|
|
285
|
+
Returns:
|
|
286
|
+
Artifact record if found, None otherwise.
|
|
287
|
+
"""
|
|
288
|
+
|
|
289
|
+
@abstractmethod
|
|
290
|
+
def list_artifact_keys(self, app_name: str, user_id: str, session_id: "str | None" = None) -> "list[str]":
|
|
291
|
+
"""List distinct artifact filenames.
|
|
292
|
+
|
|
293
|
+
Args:
|
|
294
|
+
app_name: Application name.
|
|
295
|
+
user_id: User identifier.
|
|
296
|
+
session_id: Session identifier (None for user-scoped only).
|
|
297
|
+
|
|
298
|
+
Returns:
|
|
299
|
+
List of distinct artifact filenames.
|
|
300
|
+
"""
|
|
301
|
+
|
|
302
|
+
@abstractmethod
|
|
303
|
+
def list_artifact_versions(
|
|
304
|
+
self, app_name: str, user_id: str, filename: str, session_id: "str | None" = None
|
|
305
|
+
) -> "list[ArtifactRecord]":
|
|
306
|
+
"""List all version records for an artifact, ordered by version ascending.
|
|
307
|
+
|
|
308
|
+
Args:
|
|
309
|
+
app_name: Application name.
|
|
310
|
+
user_id: User identifier.
|
|
311
|
+
filename: Artifact filename.
|
|
312
|
+
session_id: Session identifier (None for user-scoped).
|
|
313
|
+
|
|
314
|
+
Returns:
|
|
315
|
+
List of artifact records ordered by version ascending.
|
|
316
|
+
"""
|
|
317
|
+
|
|
318
|
+
@abstractmethod
|
|
319
|
+
def delete_artifact(
|
|
320
|
+
self, app_name: str, user_id: str, filename: str, session_id: "str | None" = None
|
|
321
|
+
) -> "list[ArtifactRecord]":
|
|
322
|
+
"""Delete all version records for an artifact and return them.
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
app_name: Application name.
|
|
326
|
+
user_id: User identifier.
|
|
327
|
+
filename: Artifact filename.
|
|
328
|
+
session_id: Session identifier (None for user-scoped).
|
|
329
|
+
|
|
330
|
+
Returns:
|
|
331
|
+
List of deleted artifact records (needed for content cleanup).
|
|
332
|
+
"""
|
|
333
|
+
|
|
334
|
+
@abstractmethod
|
|
335
|
+
def get_next_version(self, app_name: str, user_id: str, filename: str, session_id: "str | None" = None) -> int:
|
|
336
|
+
"""Get the next version number for an artifact.
|
|
337
|
+
|
|
338
|
+
Args:
|
|
339
|
+
app_name: Application name.
|
|
340
|
+
user_id: User identifier.
|
|
341
|
+
filename: Artifact filename.
|
|
342
|
+
session_id: Session identifier (None for user-scoped).
|
|
343
|
+
|
|
344
|
+
Returns:
|
|
345
|
+
Next version number (0-based).
|
|
346
|
+
"""
|
|
347
|
+
|
|
348
|
+
@abstractmethod
|
|
349
|
+
def create_table(self) -> None:
|
|
350
|
+
"""Create the artifact versions table if it does not exist."""
|
|
351
|
+
|
|
352
|
+
def ensure_table(self) -> None:
|
|
353
|
+
"""Create the artifact table and emit a standardized log entry."""
|
|
354
|
+
self.create_table()
|
|
355
|
+
log_with_context(
|
|
356
|
+
logger,
|
|
357
|
+
logging.DEBUG,
|
|
358
|
+
"adk.artifact.table.ready",
|
|
359
|
+
db_system=resolve_db_system(type(self).__name__),
|
|
360
|
+
artifact_table=self._artifact_table,
|
|
361
|
+
)
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"""Conversion functions between ADK models and database records.
|
|
2
|
+
|
|
3
|
+
Implements full-event JSON storage: the entire Event is serialized via
|
|
4
|
+
``Event.model_dump_json(exclude_none=True)`` into a single ``event_json``
|
|
5
|
+
column, with a small set of indexed scalar columns extracted alongside for
|
|
6
|
+
query performance. Reconstruction uses ``Event.model_validate_json()``.
|
|
7
|
+
|
|
8
|
+
Also provides scoped-state helpers that normalise ADK state prefixes
|
|
9
|
+
(``app:``, ``user:``, ``temp:``) so the shared service layer can split,
|
|
10
|
+
filter, and merge state before handing it to backend stores.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from datetime import datetime, timezone
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
from google.adk.events.event import Event
|
|
17
|
+
from google.adk.sessions import Session
|
|
18
|
+
|
|
19
|
+
from sqlspec.extensions.adk._types import EventRecord, SessionRecord
|
|
20
|
+
|
|
21
|
+
__all__ = (
|
|
22
|
+
"compute_update_marker",
|
|
23
|
+
"event_to_record",
|
|
24
|
+
"filter_temp_state",
|
|
25
|
+
"merge_scoped_state",
|
|
26
|
+
"record_to_event",
|
|
27
|
+
"record_to_session",
|
|
28
|
+
"session_to_record",
|
|
29
|
+
"split_scoped_state",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# ---------------------------------------------------------------------------
|
|
34
|
+
# Session converters
|
|
35
|
+
# ---------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def session_to_record(session: "Session") -> SessionRecord:
|
|
39
|
+
"""Convert ADK Session to database record.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
session: ADK Session object.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
SessionRecord for database storage.
|
|
46
|
+
"""
|
|
47
|
+
return SessionRecord(
|
|
48
|
+
id=session.id,
|
|
49
|
+
app_name=session.app_name,
|
|
50
|
+
user_id=session.user_id,
|
|
51
|
+
state=filter_temp_state(session.state),
|
|
52
|
+
create_time=datetime.now(timezone.utc),
|
|
53
|
+
update_time=datetime.fromtimestamp(session.last_update_time, tz=timezone.utc),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def compute_update_marker(update_time: "datetime") -> str:
|
|
58
|
+
"""Compute a stable revision marker from an update timestamp.
|
|
59
|
+
|
|
60
|
+
Uses the same format as ADK's ``StorageSession.get_update_marker()``:
|
|
61
|
+
ISO 8601 with microsecond precision, normalized to UTC.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
update_time: The session's update timestamp.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
ISO 8601 string with microsecond precision.
|
|
68
|
+
"""
|
|
69
|
+
if update_time.tzinfo is not None:
|
|
70
|
+
update_time = update_time.astimezone(timezone.utc)
|
|
71
|
+
return update_time.isoformat(timespec="microseconds")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def record_to_session(record: SessionRecord, events: "list[EventRecord]") -> "Session":
|
|
75
|
+
"""Convert database record to ADK Session.
|
|
76
|
+
|
|
77
|
+
Sets ``_storage_update_marker`` so the service layer can detect
|
|
78
|
+
concurrent modifications on subsequent ``append_event`` calls.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
record: Session database record.
|
|
82
|
+
events: List of event records for this session.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
ADK Session object with storage marker set.
|
|
86
|
+
"""
|
|
87
|
+
event_objects = [record_to_event(event_record) for event_record in events]
|
|
88
|
+
|
|
89
|
+
session = Session(
|
|
90
|
+
id=record["id"],
|
|
91
|
+
app_name=record["app_name"],
|
|
92
|
+
user_id=record["user_id"],
|
|
93
|
+
state=record["state"],
|
|
94
|
+
events=event_objects,
|
|
95
|
+
last_update_time=record["update_time"].timestamp(),
|
|
96
|
+
)
|
|
97
|
+
session._storage_update_marker = compute_update_marker(record["update_time"])
|
|
98
|
+
return session
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# ---------------------------------------------------------------------------
|
|
102
|
+
# Event converters (full-event JSON storage)
|
|
103
|
+
# ---------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def event_to_record(event: "Event", session_id: str) -> EventRecord:
|
|
107
|
+
"""Convert ADK Event to database record using full-event JSON storage.
|
|
108
|
+
|
|
109
|
+
The entire Event is serialized into ``event_json`` via Pydantic's
|
|
110
|
+
``model_dump_json(exclude_none=True)``. A small number of indexed scalar
|
|
111
|
+
columns are extracted alongside for query performance.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
event: ADK Event object.
|
|
115
|
+
session_id: ID of the parent session.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
EventRecord for database storage.
|
|
119
|
+
"""
|
|
120
|
+
return EventRecord(
|
|
121
|
+
session_id=session_id,
|
|
122
|
+
invocation_id=event.invocation_id,
|
|
123
|
+
author=event.author,
|
|
124
|
+
timestamp=datetime.fromtimestamp(event.timestamp, tz=timezone.utc),
|
|
125
|
+
event_json=event.model_dump(exclude_none=True, mode="json"),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def record_to_event(record: "EventRecord") -> "Event":
|
|
130
|
+
"""Convert database record to ADK Event.
|
|
131
|
+
|
|
132
|
+
Reconstruction is lossless: the full Event is restored from
|
|
133
|
+
``event_json`` via ``Event.model_validate_json()``.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
record: Event database record.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
ADK Event object.
|
|
140
|
+
"""
|
|
141
|
+
return Event.model_validate(record["event_json"])
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
# ---------------------------------------------------------------------------
|
|
145
|
+
# Scoped-state helpers
|
|
146
|
+
# ---------------------------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def filter_temp_state(state: "dict[str, Any]") -> "dict[str, Any]":
|
|
150
|
+
"""Return a copy of *state* with all ``temp:`` keys removed.
|
|
151
|
+
|
|
152
|
+
``temp:`` keys are process-local/session-runtime state and must never be
|
|
153
|
+
written to persistent storage.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
state: ADK state dictionary (may contain ``temp:`` prefixed keys).
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
A new dict without any ``temp:``-prefixed keys.
|
|
160
|
+
"""
|
|
161
|
+
return {k: v for k, v in state.items() if not k.startswith("temp:")}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def split_scoped_state(state: "dict[str, Any]") -> "tuple[dict[str, Any], dict[str, Any], dict[str, Any]]":
|
|
165
|
+
"""Split state into app-scoped, user-scoped, and session-scoped buckets.
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
state: Full session state dict (temp: already stripped).
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
Tuple of (app_state, user_state, session_state).
|
|
172
|
+
app_state: keys starting with "app:"
|
|
173
|
+
user_state: keys starting with "user:"
|
|
174
|
+
session_state: all other keys
|
|
175
|
+
"""
|
|
176
|
+
app_state: dict[str, Any] = {}
|
|
177
|
+
user_state: dict[str, Any] = {}
|
|
178
|
+
session_state: dict[str, Any] = {}
|
|
179
|
+
for k, v in state.items():
|
|
180
|
+
if k.startswith("app:"):
|
|
181
|
+
app_state[k] = v
|
|
182
|
+
elif k.startswith("user:"):
|
|
183
|
+
user_state[k] = v
|
|
184
|
+
else:
|
|
185
|
+
session_state[k] = v
|
|
186
|
+
return app_state, user_state, session_state
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def merge_scoped_state(
|
|
190
|
+
session_state: "dict[str, Any]",
|
|
191
|
+
app_state: "dict[str, Any] | None" = None,
|
|
192
|
+
user_state: "dict[str, Any] | None" = None,
|
|
193
|
+
) -> "dict[str, Any]":
|
|
194
|
+
"""Merge scoped state buckets into a single state dict.
|
|
195
|
+
|
|
196
|
+
Priority: session_state is base, app_state and user_state overlay.
|
|
197
|
+
This matches ADK's documented merge semantics on session load.
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
session_state: Per-session state.
|
|
201
|
+
app_state: App-scoped state (shared across sessions for same app).
|
|
202
|
+
user_state: User-scoped state (shared across sessions for same app+user).
|
|
203
|
+
|
|
204
|
+
Returns:
|
|
205
|
+
Merged state dict.
|
|
206
|
+
"""
|
|
207
|
+
merged = dict(session_state)
|
|
208
|
+
if app_state:
|
|
209
|
+
merged.update(app_state)
|
|
210
|
+
if user_state:
|
|
211
|
+
merged.update(user_state)
|
|
212
|
+
return merged
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Google ADK memory backend extension for SQLSpec.
|
|
2
|
+
|
|
3
|
+
Provides memory entry storage for Google Agent Development Kit using
|
|
4
|
+
SQLSpec database adapters. Memory stores are used to persist conversational
|
|
5
|
+
context across agent sessions for long-term recall.
|
|
6
|
+
|
|
7
|
+
Public API exports:
|
|
8
|
+
- SQLSpecMemoryService: Main async service class implementing BaseMemoryService
|
|
9
|
+
- SQLSpecSyncMemoryService: Sync service for sync adapters
|
|
10
|
+
- BaseAsyncADKMemoryStore: Base class for async database store implementations
|
|
11
|
+
- BaseSyncADKMemoryStore: Base class for sync database store implementations
|
|
12
|
+
- MemoryRecord: TypedDict for memory database records
|
|
13
|
+
- extract_content_text: Helper to extract searchable text from Content
|
|
14
|
+
- session_to_memory_records: Convert Session to memory records
|
|
15
|
+
- record_to_memory_entry: Convert database record to MemoryEntry
|
|
16
|
+
|
|
17
|
+
Example (async):
|
|
18
|
+
from sqlspec.adapters.asyncpg import AsyncpgConfig
|
|
19
|
+
from sqlspec.adapters.asyncpg.adk import AsyncpgADKMemoryStore
|
|
20
|
+
from sqlspec.extensions.adk.memory import SQLSpecMemoryService
|
|
21
|
+
|
|
22
|
+
config = AsyncpgConfig(
|
|
23
|
+
connection_config={"dsn": "postgresql://..."},
|
|
24
|
+
extension_config={
|
|
25
|
+
"adk": {
|
|
26
|
+
"memory_table": "adk_memory_entries",
|
|
27
|
+
"memory_use_fts": True,
|
|
28
|
+
"memory_max_results": 50,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
store = AsyncpgADKMemoryStore(config)
|
|
34
|
+
await store.ensure_tables()
|
|
35
|
+
|
|
36
|
+
service = SQLSpecMemoryService(store)
|
|
37
|
+
|
|
38
|
+
# Store completed session as memories
|
|
39
|
+
await service.add_session_to_memory(completed_session)
|
|
40
|
+
|
|
41
|
+
# Search memories
|
|
42
|
+
response = await service.search_memory(
|
|
43
|
+
app_name="my_app",
|
|
44
|
+
user_id="user123",
|
|
45
|
+
query="previous discussion about Python"
|
|
46
|
+
)
|
|
47
|
+
for entry in response.memories:
|
|
48
|
+
print(entry.content)
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
from sqlspec.extensions.adk.memory._types import MemoryRecord
|
|
52
|
+
from sqlspec.extensions.adk.memory.converters import (
|
|
53
|
+
extract_content_text,
|
|
54
|
+
record_to_memory_entry,
|
|
55
|
+
session_to_memory_records,
|
|
56
|
+
)
|
|
57
|
+
from sqlspec.extensions.adk.memory.service import SQLSpecMemoryService, SQLSpecSyncMemoryService
|
|
58
|
+
from sqlspec.extensions.adk.memory.store import BaseAsyncADKMemoryStore, BaseSyncADKMemoryStore
|
|
59
|
+
|
|
60
|
+
__all__ = (
|
|
61
|
+
"BaseAsyncADKMemoryStore",
|
|
62
|
+
"BaseSyncADKMemoryStore",
|
|
63
|
+
"MemoryRecord",
|
|
64
|
+
"SQLSpecMemoryService",
|
|
65
|
+
"SQLSpecSyncMemoryService",
|
|
66
|
+
"extract_content_text",
|
|
67
|
+
"record_to_memory_entry",
|
|
68
|
+
"session_to_memory_records",
|
|
69
|
+
)
|
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Type definitions for ADK memory extension.
|
|
2
|
+
|
|
3
|
+
These types define the database record structures for storing memory entries.
|
|
4
|
+
They are separate from the Pydantic models to keep mypyc compilation working.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
from typing import Any, TypedDict
|
|
9
|
+
|
|
10
|
+
__all__ = ("MemoryRecord",)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MemoryRecord(TypedDict):
|
|
14
|
+
"""Database record for a memory entry.
|
|
15
|
+
|
|
16
|
+
Represents the schema for memory entries stored in the database.
|
|
17
|
+
Contains extracted content from ADK events for searchable long-term memory.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
id: str
|
|
21
|
+
session_id: str
|
|
22
|
+
app_name: str
|
|
23
|
+
user_id: str
|
|
24
|
+
event_id: str
|
|
25
|
+
author: "str | None"
|
|
26
|
+
timestamp: datetime
|
|
27
|
+
content_json: "dict[str, Any]"
|
|
28
|
+
content_text: str
|
|
29
|
+
metadata_json: "dict[str, Any] | None"
|
|
30
|
+
inserted_at: datetime
|