Examples¶
Runnable scripts (see also
examples/README.md):
Script |
Lesson |
|---|---|
Library defaults ( |
|
Inspect rejections ( |
|
Sync |
|
|
|
ORM projection ( |
|
Entity |
|
SQLModel ( |
|
|
|
JSONL quarantine receipts |
make install
python examples/sqlrules_default.py
python examples/basic.py
Full copy-paste walkthrough: Quickstart.
validate_rows (no SQL)¶
result = rowguard.validate_rows(
rows=[{"id": 1, "name": "Ada", "age": 37}, {"id": 2, "name": "Legacy", "age": 12}],
model=UserRead,
on_reject="collect",
)
compile_plan (inspect without executing)¶
plan = rowguard.compile_plan(table=users, model=UserRead)
print(plan.pushdown_plan.enabled, plan.execution_id)
Raise policy¶
try:
rowguard.select(
session=session,
table=users,
model=UserRead,
on_reject="raise",
use_sqlrules=False,
)
except rowguard.RowValidationError as exc:
print(exc.row_index, exc.validation_error)