An integration package connecting Vericto (database guardrails for AI agents) and LangChain: check every SQL statement against Vericto's rules before it runs.
pip install langchain-vericto Copy PIP instructions
The LangChain integration for Vericto, database guardrails for AI agents. Vericto parses each SQL statement into an AST and checks it against deterministic rules before it runs: DELETE or UPDATE without WHERE, DROP TABLE, unbounded SELECT, and more. No LLM is involved in the decision; the same SQL always gets the same verdict.
This package gives a LangChain agent two things:
pip install -U langchain-vericto # the check tool pip install -U "langchain-vericto[sql]" # plus VerictoSQLDatabase (langchain-community, SQLAlchemy) Python 3.11 or later.
Install the Vericto CLI (it carries the engine; nothing is downloaded at run time):
npm i -g @vericto/vericto-cli # or: brew install vericto/tap/vericto vericto --version # 2.1.0 or later Check a statement:
import json from langchain_vericto import VerictoSQLCheck tool = VerictoSQLCheck(offline=True, dialect="postgres") verdict = json.loads(tool.invoke({"query": "DELETE FROM users"})) verdict["decision"] # 'BLOCKED' verdict["rule_codes"] # ['VERICTO-001'] verdict["suggested_fix"] # 'DELETE FROM users WHERE id = $1' json.loads(tool.invoke({"query": "SELECT id FROM users WHERE id = 42 LIMIT 1"}))["decision"] # 'ALLOWED' Guard a database (here SQLite; any SQLAlchemy URL works):
from langchain_vericto import VerictoSQLDatabase db = VerictoSQLDatabase.from_uri("sqlite:///shop.db", offline=True) db.run("SELECT id, total FROM orders WHERE id = 1 LIMIT 10") # runs db.run("DELETE FROM orders") # Error: Vericto blocked this query (VERICTO-001, severity critical). It was NOT executed. # Suggested fix: DELETE FROM orders WHERE id = $1 # Rewrite the query following the suggested fix and try again. The dialect comes from the engine (sqlite here). examples/quickstart.py runs all of this end to end.
Create an API key with the proxy:evaluate scope in the Vericto dashboard and register the database you are protecting. Then:
export VERICTO_API_KEY="vtro_..." export VERICTO_DATABASE_ID="..." # the registered database's id from langchain_vericto import VerictoSQLCheck, VerictoSQLDatabase tool = VerictoSQLCheck(dialect="postgres") db = VerictoSQLDatabase.from_uri("postgresql+psycopg://...") The verdicts now follow your workspace's rules, sensitive columns come back masked (rewritten_query, and the database runs the rewrite), and every evaluation has an event_id in the audit trail.
Offline mode is never chosen on its own: with no offline=True, no VERICTO_OFFLINE=1 and no API key, the first check raises vericto.VerictoConfigError. Offline mode combined with an API key raises too ("choose one"), so a missing secret can never quietly fall back to fewer rules.
# pip install "langchain-vericto[sql]" "langchain[anthropic]" from langchain.agents import create_agent from langchain.chat_models import init_chat_model from langchain_community.agent_toolkits import SQLDatabaseToolkit from langchain_vericto import VerictoSQLCheck, VerictoSQLDatabase db = VerictoSQLDatabase.from_uri("sqlite:///shop.db", offline=True) model = init_chat_model("claude-sonnet-4-6") # any chat model with tool calling toolkit = SQLDatabaseToolkit(db=db, llm=model) agent = create_agent( model=model, tools=[*toolkit.get_tools(), VerictoSQLCheck.from_database(db)], system_prompt=( "You answer questions about the shop database. Check every query with " "vericto_sql_check before running it, and never run a blocked query." ), ) agent.invoke({"messages": [{"role": "user", "content": "Delete all orders."}]}) Every query the toolkit runs goes through Vericto, whether or not the model calls the check tool first: the check tool lets it ask before it tries, the database refuses what is blocked either way.
VerictoSQLCheck returns the verdict as a JSON string; called with a ToolCall, the ToolMessage carries the same dict as its artifact. tool.check(query) returns the SDK's vericto.Verdict, and langchain_vericto.verdict_to_dict turns it into the dict.
A text with several statements gets one verdict, the strongest finding among them: SELECT 1; DELETE FROM orders is BLOCKED by VERICTO-001.
When Vericto cannot answer (network, timeout, quota, the local engine process failing):
Configuration errors (bad key, missing scope, no CLI in offline mode, an unsupported dialect) raise vericto.VerictoConfigError in both modes.
Both classes take the same connection arguments; each falls back to an environment variable.
VerictoSQLCheck also takes dialect (default postgres; the model may pass another one per call). VerictoSQLDatabase takes every SQLDatabase argument, dialect (default: the engine's), on_block ("return", default, or "raise" to raise vericto.VerictoBlocked), and context / end_user for business policies (see the Vericto SDK).
Call close() on either object when you are done: it stops the local vericto serve process (offline) or closes the HTTP pool (online). A guard passed with guard= is left to its owner.
The evaluation is done by the official Vericto SDK for Python (vericto, Apache-2.0), which this package depends on; VerictoSQLDatabase is built on the SDK's vericto.langchain integration.
uv sync # Python 3.11+, uv make lint # ruff check, ruff format --check, mypy make test # unit tests, LangChain standard tests, no network make integration_test # against the real engine (see below) uv build && uvx twine check --strict dist/* Integration tests run offline against the real engine when a Vericto CLI is on PATH or in VERICTO_CLI (VERICTO_REQUIRE_CLI=1 makes a missing CLI a failure instead of a skip), and online when VERICTO_API_KEY and VERICTO_DATABASE_ID are set. See CONTRIBUTING.md.
Apache License 2.0. See NOTICE and TRADEMARKS.md. The Vericto engine and CLI are separate programs under their own license (AGPL-3.0-only); this package talks to the CLI as a separate process and does not include it.
Both files in this release have provenance metadata.
ai-agents database-guardrails guardrails langchain sql sql-agent text-to-sql vericto
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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 15, 2026.
Both files in this release have been uploaded with provenance metadata.
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.




