Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

llama-index-tools-sqlguardllm

A guarded SQL database and tool spec for LlamaIndex, built on sqlguardllm, a deterministic SQL firewall: the model writes SQL, sqlguardllm checks and rewrites it against your policy, and only then does it run.

Status: alpha.

pip install --pre llama-index-tools-sqlguardllm

Quick start

from llama_index.core.query_engine import NLSQLTableQueryEngine
from llama_index.tools.sqlguardllm import GuardedSQLDatabase, SQLGuardToolSpec
from sqlalchemy import create_engine
from sqlguardllm import Guard, Policy

policy = Policy(
    dialect="sqlite",
    tables={"customers", "invoices"},
    hidden_columns={"customers.email"},
    row_filters={"invoices": "branch_id IN ({user.branches})"},
    max_rows=100,
)
db = GuardedSQLDatabase(
    create_engine("sqlite:///sales.db"),  # a read-only user in production
    guard=Guard(policy),
    context_fn=lambda: {"user": {"branches": [1, 2]}},  # from the session, never the model
)
engine = NLSQLTableQueryEngine(sql_database=db, tables=sorted(policy.tables), llm=llm)
tools = SQLGuardToolSpec(db).to_tool_list()  # run_sql, list_tables, describe_table for agents

GuardedSQLDatabase is a drop-in for NLSQLTableQueryEngine and SQLTableRetrieverQueryEngine. A refused query raises QueryRefused (a GuardViolation) whose message lists the violation codes, for example Query refused: [hidden_column] customers.email is a hidden column; the engines answer with it and the tool spec returns it as Error: ... so the model can rewrite the query.

Safety notes

  • Hidden columns never appear in describe_table or in the schema shown to the model; only tables in the policy are exposed.
  • sample_rows_in_table_info must be 0 and schema= is not supported (both act outside the guard); use the policy's default_schema.
  • Keep the layers under the guard: a read-only database user and a statement timeout.

More at https://github.com/jmmana/sqlguardllm.

Metadata

Release files for llama-index-tools-sqlguardllm 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-tools-sqlguardllm 0.1.0a1
File Size Uploaded Provenance Actions
llama_index_tools_sqlguardllm-0.1.0a1.tar.gz 5.3 kB With provenance Details for llama_index_tools_sqlguardllm-0.1.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-tools-sqlguardllm 0.1.0a1
File Interpreter ABI Platform Actions
llama_index_tools_sqlguardllm-0.1.0a1-py3-none-any.whl Python 3 none any Details for llama_index_tools_sqlguardllm-0.1.0a1-py3-none-any.whl

Total release size: 10.2 kB

Release files / llama_index_tools_sqlguardllm-0.1.0a1.tar.gz

Download URL llama_index_tools_sqlguardllm-0.1.0a1.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
16c1d038c864869767d7be18449ffcadd8c4eb87f510e96d2bcef5935109108a
BLAKE2b-256 checksum
How to use checksums
114c4c7f61a6209dea3b24f5e97fb40f34e89a0ab51972b0290f91e8b14fd752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

Release files / llama_index_tools_sqlguardllm-0.1.0a1-py3-none-any.whl

Download URL llama_index_tools_sqlguardllm-0.1.0a1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f6e533e106668e44612fda5509758f4ddc8a7b319245a53e38781dace34b873
BLAKE2b-256 checksum
How to use checksums
7d66de285b4e522426df5cc447b83ea975a69a53892cb9f56c694a658524668b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

Security for llama-index-tools-sqlguardllm 0.1.0a1

Provenance

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llama_index_tools_sqlguardllm-0.1.0a1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

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

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page