haltsql (Python)
Python client for HaltSQL, the policy firewall for LLM-generated PostgreSQL.
pip install haltsql # httpx (+ the bundled engine on Linux x86_64/aarch64 and macOS arm64)
pip install 'haltsql[psycopg]' # + guarded execution on psycopg 3
pip install 'haltsql[asyncpg]' # + guarded execution on asyncpg
import psycopg
from haltsql import HaltSQLClient, QueryDenied, guard
hs = HaltSQLClient.from_env() # HALTSQL_URL, HALTSQL_TOKEN, HALTSQL_TIMEOUT, HALTSQL_CA_FILE, ...
with psycopg.connect(DSN) as conn:
try:
result = guard.execute(conn, model_sql, {"tenant_id": session.tenant_id},
verifier=hs, statement_timeout_ms=5000, max_rows=500)
print(result.columns, result.rows)
except QueryDenied as denied:
feedback = [(r.code, r.hint) for r in denied.verdict.reasons] # give to the model
HaltSQLClient/AsyncHaltSQLClient: the sidecar HTTP API, with default timeouts (2 s per attempt), bounded retries, TLS verification on by default (private CA viaverify=, mutual TLS viacert=), and a response size cap. Fail closed: any error raises; nothing is ever treated as allowed. The token never appears inrepr()or error messages.Verdict,Reason,BindParam: typed verdicts;verdict.bind_args()returns positional parameters for$1..$n.guard.execute/guard.execute_async: verify, then run exactly the verified string with the bound parameters (psycopg 3, asyncpg, SQLAlchemy + psycopg 3).NativeVerifier/AsyncNativeVerifier: verify in-process with the engine bundled in platform wheels (manylinux_2_28 x86_64/aarch64, macOS arm64), with no sidecar:NativeVerifier("policy.yaml").verify(sql, ctx), ~0.1 ms per call. Backendslibrary(ctypes) orprocess(one long-lived CLI child); envHALTSQL_LIB,HALTSQL_BIN,HALTSQL_NATIVE=0|library. Create it afterfork()(e.g. gunicornpost_fork).LocalVerifier: verify with thehaltsqlCLI (bundled,$HALTSQL_BINorPATH), one process per call.haltsql.testing:FakeSidecar,FakeVerifier,make_verdictfor your tests.
Full guide: docs/sdk-python.md.
Development
python3 -m venv .venv && .venv/bin/pip install -e '.[psycopg,asyncpg,test]'
.venv/bin/pytest -q
Tests that need the real binaries (_build/default/bin/..., or
HALTSQL_BIN / HALTSQL_SERVER_BIN) or the lab Postgres (make -C lab up) are
marked integration and skip when those are missing. native tests need
_build/default/native/libhaltsql.so (or HALTSQL_LIB); set
HALTSQL_REQUIRE_NATIVE=1 to fail instead of skip.
Platform wheel (bundles libhaltsql and the CLI; output in dist/):
scripts/build_wheel.sh # dune release build, strip, tag, delocate/auditwheel
scripts/build_wheel.sh --pure # py3-none-any wheel without the engine
HALTSQL_WHEEL=$(ls dist/*.whl) .venv/bin/pytest -q -m wheel # install + smoke-test it
Metadata
Release files for haltsql 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| haltsql-0.0.2.tar.gz | 59.5 kB | With provenance | Details for haltsql-0.0.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| haltsql-0.0.2-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for haltsql-0.0.2-py3-none-manylinux_2_28_x86_64.whl |
| haltsql-0.0.2-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details for haltsql-0.0.2-py3-none-manylinux_2_28_aarch64.whl |
| haltsql-0.0.2-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details for haltsql-0.0.2-py3-none-macosx_11_0_arm64.whl |
| haltsql-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for haltsql-0.0.2-py3-none-any.whl |
Total release size: 21.4 MB
Release files / haltsql-0.0.2.tar.gz
| Download URL | haltsql-0.0.2.tar.gz |
|---|---|
| Size | 59.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80d35f13759a9d1118f2edd6bb420d3623069e8422f9de6d3e9e6fa2fe4d793c
|
|
BLAKE2b-256 checksum How to use checksums |
70746f2b804c01636f5fd82f6f9a4fc043407f6d0199044ec0d341fdc8a5a136
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Nov 10, 2026.
Transparency logRelease files / haltsql-0.0.2-py3-none-manylinux_2_28_x86_64.whl
| Download URL | haltsql-0.0.2-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
661432b78530e636a51ca1b946f2160f9c0f08feea320386fe9d11b4c69108ea
|
|
BLAKE2b-256 checksum How to use checksums |
81de30b0132c284d32cde5e99fc6da71d0436c796f7f9fafefb9d5b28a4bab03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Nov 10, 2026.
Transparency logRelease files / haltsql-0.0.2-py3-none-manylinux_2_28_aarch64.whl
| Download URL | haltsql-0.0.2-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 7.3 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
fff799cde6946762544c03afd0d7bc6bddc694ea7671121b90d5ee09e2977953
|
|
BLAKE2b-256 checksum How to use checksums |
ce9b903991e97ecf8cb12a4a3aeaed22aee7b198c0318bad80787e88f6a8f6f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Nov 10, 2026.
Transparency logRelease files / haltsql-0.0.2-py3-none-macosx_11_0_arm64.whl
| Download URL | haltsql-0.0.2-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 7.3 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
85b811dd50ca1d6ed49357374d70a9651ad2ea829ad01fc72b86044b2fcaf4b4
|
|
BLAKE2b-256 checksum How to use checksums |
83b25e396b0b8ef34c24d046569e92f0cc532c1869137cba243a20fc935ae34a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Nov 10, 2026.
Transparency logRelease files / haltsql-0.0.2-py3-none-any.whl
| Download URL | haltsql-0.0.2-py3-none-any.whl |
|---|---|
| Size | 44.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
56d49bf163c94e7c7a27fbebc0af83abd9f0125bbcef138e4dc42045b7f89628
|
|
BLAKE2b-256 checksum How to use checksums |
d5fc2bea3348dc0bb9e41cee7ea5eb4dd803fb01154779e44f688c6e32836597
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Nov 10, 2026.
Transparency logSecurity for haltsql 0.0.2
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
All 5 files in this release have been uploaded with provenance metadata.
Attestation for haltsql-0.0.2.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 Nov 10, 2026.
Transparency logA 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.