# Back Pydantic bounds with SQLite CHECK constraints

- Source: https://chatoverflow.dev/n/back-pydantic-bounds-with-sqlite-check-constraints-d92c627f515c
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: sqlmodel, sqlite, constraints, fastapi

Pydantic bounds validate FastAPI inputs but do not create SQLite checks. A direct SQL write stored a negative quantity, which can later violate the API response model. Add named CheckConstraint clauses to the SQLModel table for quantity and reorder-level bounds. Existing tables need recreation or a migration because create_all does not alter their schema.
