Skip to main content Switch to mobile version Change of provenance The repository or configuration that created this release differ from a previous release. View details.
This release is a pre-release and may not be stable for production use.
The SQL firewall for LLM apps: validate SQL written by AI and rewrite it read-only, allowlisted, row-filtered and limited.
pip install sqlguardllm==0.1.0a2 Copy PIP instructions
Your model writes SQL. sqlguardllm 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 sqlguardllm 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, EXEC or row locks, at any depth. A DELETE hidden 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.*, DuckDB read_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.
Source, design and attack gallery: https://github.com/jmmana/sqlguardllm
Threat model: https://github.com/jmmana/sqlguardllm/blob/main/docs/THREAT_MODEL.md
Report a bypass privately: https://github.com/jmmana/sqlguardllm/security/advisories/new
Licensed under Apache-2.0.
The repository or configuration that created this release differ from a previous release.
Apache-2.0 View SPDX License List
ai-safety guardrails llm nl2sql prompt-injection row-level-security security sql sqlglot text-to-sql
Development Status 3 - Alpha
Intended Audience Developers
Operating System OS Independent
Programming Language Python :: 3
Scientific/Engineering :: Artificial Intelligence
Release files for sqlguardllm 0.1.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 58.7 kB
Release files / sqlguardllm-0.1.0a2.tar.gz
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Release files / sqlguardllm-0.1.0a2-py3-none-any.whl
Security for sqlguardllm 0.1.0a2
The repository and configuration that created this release differ from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
- Removed 0.1.0a1 github.com/jmmana/sqlguard
+ Added 0.1.0a2 github.com/jmmana/sqlguardllm
With provenance sqlguardllm-0.1.0a2.tar.gz Nov 25, 2026
Attestation for sqlguardllm-0.1.0a2.tar.gz
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Dec 3, 2026 2 release files Full provenance
Dec 1, 2026 2 release files Full provenance
Nov 30, 2026 2 release files Full provenance
Nov 27, 2026 2 release files Full provenance
Nov 26, 2026 2 release files Full provenance
Nov 25, 2026 2 release files Full provenance
Nov 25, 2026 2 release files Change of provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




