HOW SQLMODEL
ACTUALLY WORKS
SQL databases in Python, designed for simplicity and compatibility with FastAPI. Conventions, patterns, and architecture extracted from the fastapi/sqlmodel repository by sourcebook.
WHAT_MATTERS
-
→
Uses FastAPI endpoints for routing — follow this pattern, don't add REST routes directly
KEY_FINDINGS
FastAPI project. Use Pydantic models for request/response schemas, not raw dicts.
HIGHUses SQLAlchemy/SQLModel for ORM. Database sessions must be properly closed (use dependency injection).
HIGHUses pytest. Test files should be named `test_*.py` or `*_test.py`.
HIGHTests live in a separate test/ directory, mirroring src/ structure. New tests go there, not next to source files.
HIGHAPI endpoints use FastAPI endpoints. Follow this pattern for new routes.
HIGH14 files use FastAPI endpoints
Tests use pytest.
HIGH20 test files
Route definitions live in: docs_src/tutorial/fastapi, docs_src/tutorial/fastapi/update, docs_src/tutorial/fastapi/teams. Add new endpoints here.
HIGH3 route directories