mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
Foundation for the multi-phase migration of the proxy persistence layer
from Prisma (prisma-client-py==0.11.0) to SQLModel/SQLAlchemy. This change
is non-functional at runtime: nothing imports the new package from the
existing proxy code paths.
Adds:
* litellm/proxy/db/sqlmodel/schema_parser.py
Pure-Python parser for the subset of Prisma DSL used by schema.prisma.
* litellm/proxy/db/sqlmodel/_generate.py
Code generator that emits SQLModel class definitions from a parsed
schema. Produces Black-formatted output. Run manually after schema
changes:
uv run python -m litellm.proxy.db.sqlmodel._generate \
--schema schema.prisma \
--out litellm/proxy/db/sqlmodel/models.py
* litellm/proxy/db/sqlmodel/models.py
SQLModel classes for all 64 Prisma models, hand-editable. Composite
primary keys, @@unique, @@index (incl. map: '...' renames), @@map,
String[] arrays, BigInt, Json/JSONB, @updatedAt, @default(uuid()/now()),
and reserved Python attribute names (metadata -> metadata_) are all
preserved structurally.
* tests/test_litellm/proxy/db/sqlmodel_orm/{test_schema_parser,test_parity}.py
20 tests covering the parser unit cases, structural parity between
every Prisma model and its SQLModel class (columns, nullability, type
category, ARRAY-ness, primary keys, uniques, indexes), and a strict
guard that the committed models.py is byte-identical to a fresh
generator run.
* litellm/proxy/db/sqlmodel/README.md
Phase 1 plan and the explicit out-of-scope items reserved for later
phases (session abstraction, raw-SQL hotspot port, per-table call site
migration, replacement of PrismaWrapper / RoutingPrismaWrapper /
exception classifier, Alembic migrations, Prisma teardown).
Dependencies:
* Adds 'sqlmodel>=0.0.22,<1.0' to the extra_proxy optional group. This
pulls in SQLAlchemy as a transitive dep. Existing Prisma deps are
unchanged.
Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
|
||
|---|---|---|
| .. | ||
| db_transaction_queue | ||
| mcp_server | ||
| sqlmodel_orm | ||
| test_check_migration.py | ||
| test_create_views.py | ||
| test_db_spend_update_writer.py | ||
| test_db_url_settings.py | ||
| test_exception_handler.py | ||
| test_exception_handler_reconnect_retry.py | ||
| test_prisma_client.py | ||
| test_prisma_self_heal.py | ||
| test_rds_iam_token_expiry.py | ||
| test_routing_prisma_wrapper.py | ||
| test_tool_registry_writer.py | ||