PYPI PACKAGE AUDIT
v0.1.0a2
Enterprise Healthy
sqlguardllm
The SQL firewall for LLM apps: validate SQL written by AI and rewrite it read-only, allowlisted, row-filtered and limited.
955
/ 1000
Quick Install
pip install sqlguardllm
1. Governance
200/200
2. PEP Metadata
200/200
3. Security
200/200
4. Docs & SEO
155/200
5. CI Engineering
200/200
📣 Share Audit:
Share this report and visual preview in the current language
PYPI TELEMETRY
Downloads & Community Adoption
Last 30 days (without mirrors)
Last 7 days
162
Last 30 days
162
Total (180 days)
162
Health & Engineering Analysis (5 Pillars)
1. Governance & Community200 / 200 ▾
LICENSE✓ 50 pts
SECURITY.md✓ 50 pts
CONTRIBUTING.md✓ 50 pts
CODE_OF_CONDUCT.md✓ 50 pts
2. PEP Metadata & Packaging200 / 200 ▾
Wheel (.whl)✓ 50 pts
pyproject.toml✓ 50 pts
Project URLs✓ 50 pts
Trove Classifiers✓ 50 pts
3. Security & Supply Chain200 / 200 ▾
Zero CVEs (OSV)✓ 60 pts
Trusted Publishing (OIDC)✓ 50 pts
Snyk / Audit Link✓ 40 pts
HTTPS Repository✓ 50 pts
4. Documentation, SEO & Ecosystem155 / 200 ▾
Structured README✓ 60 pts
Read the Docs✓ 50 pts
Django Packages✕ 0 pts
Website / Technical Articles✓ 45 pts
5. Engineering, CI & Quality200 / 200 ▾
Automated Tests✓ 65 pts
GitHub Actions CI✓ 65 pts
CHANGELOG.md✓ 35 pts
Env & Lockfile (uv/rye/poetry/pdm/hatch)✓ 35 pts
README & DOCS
PyPI Metadata v0.1.0a2
Official Documentation & Usage Guide — sqlguardllm
Show full original documentation (English README) ▾
sqlguard — the SQL firewall for LLM apps
Your model writes SQL. sqlguard makes sure it can only read what it's allowed to read: one read-only statement, allowlisted tables and columns, row-level filters per user, and a row limit, in any dialect sqlglot understands.
pip install sqlguardllm
from sqlguard import Guard, Policy
guard = Guard(
Policy(
dialect="postgres",
tables={"invoices", "branches", "customers"},
hidden_columns={"customers.email"},
row_filters={"invoices": "branch_id IN ({user.branches})"},
max_rows=1000,
)
)
result = guard.check(sql_from_llm, context={"user": {"branches": [1, 2]}})
if result.ok:
rows = db.execute(result.sql) # read-only, row-filtered, limited
else:
print(result.messages) # ["The query tries to change data or structure (DELETE)"]
What it guarantees
- One statement that is a query. Nothing stacked after a
;. - Read-only across the whole syntax tree: no
INSERT,UPDATE,DELETE,MERGE,SELECT … INTO, DDL,COPY,ATTACH,PRAGMA,EXECor row locks, at any depth. ADELETEhidden in a CTE is caught. - Allowlisted tables and hidden columns, CTE-aware;
SELECT *, whole-row references and predicates on hidden columns are rejected. - Denied functions per dialect: file readers, sleeps, shells, network calls and functions that run SQL from a string (
pg_read_file,query_to_xml,LOAD_FILE,OPENROWSET,DBMS_PIPE.*, DuckDBread_csv…). - Row-level filters: every occurrence of a table becomes a filtered derived table, with the user's values bound as escaped literals.
- Row limit in the dialect's own syntax (
LIMIT,TOP,FETCH FIRST). - Fails closed: what can't be understood is rejected with a reason.
Pure Python, one dependency (sqlglot), no network, no LLM. Status: alpha — the API may still change before 1.0; violation codes are stable.
Learn more
- Source, design and attack gallery: https://github.com/jmmana/sqlguard
- Threat model: https://github.com/jmmana/sqlguard/blob/main/docs/THREAT_MODEL.md
- Report a bypass privately: https://github.com/jmmana/sqlguard/security/advisories/new
The distribution is named sqlguardllm on PyPI; the import name is sqlguard. Licensed under Apache-2.0.