SQLRules documentation¶
Constraint metadata → WHERE expressions
Compile constraints into WHERE rules
SQLRules turns a safe subset of Pydantic field constraints into deterministic SQLAlchemy expressions—no database connection, plugins for dialect operators. It compiles Field metadata, not model instance values.
Pick the path that matches how you work:
Compile constraints from models. Install sqlrules, map a Pydantic model to a table, and pass where(rules) into SQLAlchemy.
Extend the compiler. Register dialect translators for regex, JSON, arrays, and custom operators with a versioned plugin API.
Fit and non-goals. What SQLRules is, what it refuses to do, and how the API tiers stay stable.
Contracts and autodoc. Narrative API tiers plus generated members from the installed package.
Not a query builder
SQLRules does not connect to a database, generate SQL strings, or turn
validated request payloads into WHERE predicates. It only compiles
supported constraint metadata into expressions. See
design philosophy.
pip install "sqlrules>=1,<2"
— optional dialects via pip install "sqlrules-postgresql>=1,<2" (or sqlite / mysql / mssql).
pattern needs a dialect plugin.
Documentation map¶
Getting started
Questions?
See the FAQ or troubleshooting.
How-to guides
Reference
Internals