MerchantryTidbits

data-storage / library

SQLModel

Capability: SQLModel

Use it when

  • A Python or FastAPI project repeats the same field annotations across SQLAlchemy and Pydantic models and needs shared typed definitions without giving up SQLAlchemy compatibility
  • You want typed database rows and editor completion while still defining separate public, create, update, and table models where their fields or permissions differ

What it solves

Not the fit when

  • Using one table model as every request and response schema when it contains secrets, server-controlled fields, or fields users must not set
  • Non-Python stacks
  • Databases unsupported by SQLAlchemy
  • Replacing a migration tool; the retained README demonstrates `create_all`, not migrations
  • javascript or typescript orm needs
  • nosql or document database access
  • schema migration management
  • vector similarity search

Install

uv add sqlmodel (or pip install sqlmodel)

Invoke

Define class Hero(SQLModel, table=True) with typed fields, then SQLModel.metadata.create_all(engine) and use Session(engine) with select() to insert and query rows; the same class works as a Pydantic model in FastAPI.

Alternatives

No reviewed alternatives recorded yet.