TeaQL Python SDK
Sensitive log data
Runtime diagnostic logs redact payload values by default, before delivery to file, console, buffers, or custom logging sinks. Selecting a diagnostic sink alone does not authorize plaintext. For controlled troubleshooting only:
export TEAQL_ALLOW_SENSITIVE_PLAINTEXT_LOGS=I_UNDERSTAND_SENSITIVE_DATA_MAY_BE_WRITTEN_TO_DISK
Only this exact value enables plaintext permission; empty values, true, and
whitespace variants do not. Enabling it emits a warning. Credential-classified
fields remain redacted. The flag does not force every sink to expose values.
SQL without reliable field/literal provenance may be suppressed and marked
NOT REPLAYABLE. Execution parameters and persisted business data are unchanged.
Do not put sensitive data in free-text comments or purpose declarations. TeaQL cannot govern arbitrary application prints or independent driver loggers; configure those separately. This setting does not erase older plaintext files. Restrict access and retention when using plaintext diagnostics, then unset the variable and restart processes when troubleshooting is complete.
TeaQL Python SDK is a runtime engine and toolkit for building data-driven business applications. It provides seamless integration with the TeaQL ecosystem, fully aligned with the teaql-rs baseline.
Recommended Agent Harness
When building database-backed applications with the TeaQL Python runtime, we recommend using it together with the TeaQL Agent Kit. The Agent Kit is TeaQL's continuously evolving Harness Engineering method. It gives coding agents a model-mediated, executable workflow for domain modeling, deterministic evaluation and repair, code generation, implementation, and evidence-based verification as the generator and runtimes evolve.
1. Minimum Version Requirements
- Python: 3.10+ (Recommended 3.12+)
- Testing:
pytest7.4+ - Dependencies:
pydantic>= 2.0,aiosqlite,aiomysql,asyncpg
2. Tests Performed
After rigorous AST semantic analysis and manual verification, this SDK has successfully passed the following tests:
- ✅ 100% API Signature and Logic Parity: Scanned with Tree-Sitter and implemented all internal methods and logic to match the Rust baseline.
- ✅
teaql.coreCore Tests: Extensively tested attribute extraction, safe nullability checks, and relationship building forValue,GraphNode,Entity,Mutation,Query,Expr, andSafeExpression. - ✅
teaql.runtimeRuntime Tests: Verified the context propagation ofUserContextand the complete lifecycle hooking forrecord_sql_logandrecord_metadata_log. - ✅
teaql.sql/teaql.data_serviceTests: Tested the SQL AST compilation engine and the underlying command dispatch mechanism. - ✅ Provider & External Integrations: Includes integration tests for the SQLite driver and FastAPI web endpoints.
3. Available Modules
The SDK's organizational architecture strictly mirrors the Rust version:
teaql.core: Provides core underlying data structures (e.g.,Value,GraphNode,Entity,SelectQuery,MutationRequest).teaql.data_service: Defines universal data service abstractions, handling structured inputs and outputs.teaql.sql: Provides a cross-dialect SQL compilation executor, translating ASTs into physical queries for various databases.teaql.runtime: Contains the pipeline and application context mechanisms (e.g.,UserContext, environment mounts).teaql.provider: Packages for physical database drivers and the canonical TeaQL Federal Protocol client.teaql.web: Web framework integration middleware (e.g.,FastAPI/Starlette).
4. Features
- Entity & Value Mapping: Provides type-safe mapping between native Python types and TeaQL core primitives (I64, Text, F64, Null, etc.).
- SQL Compilation & AST Building: A dynamic, secure SQL query builder that generates standardized
INSERT,UPDATE,DELETE, andSELECTstatements while abstracting away dialect differences. - Facet Aggregation & Grouping: Out-of-the-box support for multi-dimensional facet aggregations, group-bys, and hierarchical data processing.
- Provider Support: Highly extensible asynchronous database connectivity (integrating third-party async drivers like
aiosqlitethrough a unified Transport layer). - Context & Logging Management: Built-in support for lifecycle context passing, end-to-end tracing, and SQL execution log interception and dispatch.
- Governed Mutation Policy: An application-owned policy can review an immutable whole-graph plan after Checker/Fix and before the first provider mutation. Exact policy identity and approval state are retained with audit evidence. Missing customer policy or approval emits stable warnings without changing persistence semantics; an explicit denial fails closed.
- TeaQL Federal Protocol Client:
TeaQLFederalClientandTfpHttpProviderexecute governed canonical TFP v1 queries and audited mutations against a remote TeaQL endpoint such as Rust. Direct query execution returnsSmartList; Python intentionally does not expose a TFP server endpoint.
from teaql.provider.tfp_client import FederalQuery, TeaQLFederalClient
client = TeaQLFederalClient("https://orders.example.com/tfp")
orders = await client.execute_query(FederalQuery(
entity="CustomerOrder",
filter_condition={"status": {"$eq": "NEW"}},
comment="List new orders",
purpose="Render operations queue",
))
await client.aclose()
Security Foundation Status
Python currently provides governed local SQL execution and a TFP client; it does not claim a public TFP server endpoint. Application queries retain non-empty comment/purpose and audited mutations retain their audit reason. Runtime logging should keep parameterized SQL and intent separate from any restricted value-bearing diagnostic output.
Portable UserContext opaque entity references are not implemented in the
Python runtime yet. Until that capability is added, applications must not
invent a Python-specific token format or serialize internal ID/version pairs as
if they were the TeaQL portable contract. A Python TFP client may carry an
opaque token issued by a trusted Java, Rust, Go, or .NET backend, but it must
not decode, rewrite, or mint that token.
The planned wire format, fail-closed behavior, shared golden vector, and exact development-only acknowledgement are maintained in the canonical opaque entity reference contract. Opaque tokens never replace the backend's authorization, tenant, ownership, role, or optimistic-version checks.
Mutation Policy installation
Policy implementations are installed from trusted application startup through
UserContext; request JSON cannot select or replace them. Built-in SQL and TFP
providers enter the same governed boundary.
context = (
UserContext.new()
.with_mutation_policy_registry(policy_registry)
.with_mutation_policy_approval_provider(approval_provider)
.with_mutation_governance_sink(warning_sink)
)
Generated graph saves call preflight_mutation(...) for every operation before
the first provider write. See the repeatable
examples/mutation-policy example for allow,
approval, audit propagation, and zero-write denial evidence.
To run test validations and business logic simulations locally, simply run pytest in the project root.
Metadata
Release files for teaql 0.2.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| teaql-0.2.9.tar.gz | 87.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| teaql-0.2.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 186.3 kB
Release files / teaql-0.2.9.tar.gz
| Download URL | teaql-0.2.9.tar.gz |
|---|---|
| Size | 87.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11551b5c9da4d40783a1431e5dcec8400fa51398ffbdcd4bf77e9565a4f25692
|
|
BLAKE2b-256 checksum How to use checksums |
e1c1bd1c2ba63edb0edc4ebcf94541a90ba27c38fb2e33095932bcfd825d4313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 30, 2026.
Transparency logRelease files / teaql-0.2.9-py3-none-any.whl
| Download URL | teaql-0.2.9-py3-none-any.whl |
|---|---|
| Size | 98.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b34878c2897d088871dc8906e3fb154333e191b1895a630a4d789d7e579ec4c
|
|
BLAKE2b-256 checksum How to use checksums |
f63ac392bc4c01460fb6427860634ef702035a533153c42fe84f091750d4f781
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 30, 2026.
Transparency log