Skip to main content

AetherDialect - The deterministic Text-to-SQL engine

aetherdialect turns analytical questions into read-only SELECT pipelines: a structured intent representation, multi-stage validation (including dialect EXPLAIN), template reuse from accepted answers, and bounded learning from rejections. The language model fills bounded slots in that intent; it does not author unconstrained SQL.

Why this exists

Teams need answers from relational data without shipping opaque generated SQL. AetherDialect targets analysts and integrators who want a repeatable path from question to result: the same question can return cached SQL with no model round-trip, schema drift surfaces as an explicit migration stop instead of silent breakage, and every generated statement is checked against the catalog and engine before it runs.

Install

pip install aetherdialect
pip install "aetherdialect[mysql]"        # MySQL
pip install "aetherdialect[mariadb]"      # MariaDB
pip install "aetherdialect[sqlserver]"    # SQL Server
pip install "aetherdialect[oracle]"       # Oracle
pip install "aetherdialect[postgresql]"   # PostgreSQL
pip install "aetherdialect[redshift]"     # Amazon Redshift
pip install "aetherdialect[databricks]"   # Databricks
pip install "aetherdialect[snowflake]"    # Snowflake
pip install "aetherdialect[bigquery]"     # Google BigQuery
pip install "aetherdialect[mysql,postgresql]"  # pick any subset

Requires Python 3.11 or newer. SQLite and DuckDB need no extra install. Configure the LLM and database via a TOML config_file (recommended) and/or process environment; the full key list lives in the API reference.

Quick start

New here? Follow the Getting started guide: try the offline sandbox first, then wire any supported database with inlined TOML examples, first-run profiling expectations, and run_interactive vs session().

No database yet? Try the sandbox:

from aetherdialect import Sandbox

with Sandbox() as sandbox:
    engine = sandbox.engine()
    with engine.session() as session:
        step = session.accept_until_done("How many films are there?")
    print(step.sql)

See the Sandbox guide.

What makes this different

  • Constant-learning cache: exact q_norm reuse returns SQL with zero LLM calls; near-paraphrases (token Levenshtein at most 2) reuse the same template with one bounded LLM call that only extracts parameters. (How it works)

  • Structure documents are JSON you read, edit, and version via export_structure / apply_structure. Every structure edit (roles, sensitivity, added or suppressed foreign keys, primary key endorsements) replays on every cache invalidation. Suggested caller-owned persistence name: schema_structure.json; the library persists the applied document as applied_structure.json. (API reference)

  • Migration is never silent. When the catalog changes structurally, the engine writes a schema_migration_map.json skeleton and stops. You decide the action; it resumes. (User guide)

  • Generated SQL passes through four validation layers (intent JSON, dialect AST, schema/catalog alignment, dialect EXPLAIN). The LLM never emits raw SQL; it fills bounded slots in a structured intent IR. (Security)

  • Reader / writer split is built in. Many readers can ask questions; writer-mode turns drain write_queue.jsonl at turn start under the artifacts lock so learning persists without readers touching the partitioned template store. Readers keep learning session-local and do not enqueue durable write-queue events. (How it works — Concurrent sessions)

At a glance

Supported engine selections (12): SQLite, DuckDB, CSV (.csv and .xlsx), MySQL, MariaDB, SQL Server, PostgreSQL, Amazon Redshift, Databricks, Snowflake, Google BigQuery, Oracle. Install aetherdialect[csv] for file uploads. Set [engine] selected or AETHERDIALECT_ENGINE when more than one block is configured.

SQL scope: DML/DDL, set operators inside one statement (UNION/EXCEPT/INTERSECT), lateral joins, recursive CTEs, correlated subqueries beyond CTE shapes, row-skipping OFFSET/FETCH, and window/JSON outside the IR whitelist are refused. The engine never emits literal EXISTS, NOT EXISTS, or bare DISTINCT ON SQL — but existence (semi-join), absence and set-difference over keys (anti-join), and per-partition top-one are supported via first-class intent IR and compiled deterministically. Details: Supported intent constructs · Refused constructs.

What reaches the LLM: Prompt-safe schema metadata (visible table/column names, types, roles, descriptions, capped enum heads), the user question, bounded intent JSON, join-choice candidates, optional notes file and DDL file content when you configure them on EngineContext, and summarised failure feedback — not raw warehouse row dumps. Inventory: Security — LLM context.

What "safe" means here: SELECT-only enforcement, forbidden-SQL regex, dialect AST validation, schema alignment, and EXPLAIN before execution; sensitivity tiers (User guide) and deny lists gate what appears in prompts. This complements your database IAM and network controls; it does not replace them. Detail: Security — Threat model.

Production checklist: least-privilege DB role; explicit stable artifacts_dir on durable storage; reviewed notes_file / EngineContext.sql_file content; config_file or env secrets not committed; one writer process per artifacts_dir; plan for schema_migration_map.json when the catalog changes.

No warehouse or LLM keys yet? Sandbox guideGetting startedUser guide.

Reading order

Doc When to read it
Getting started First run: offline sandbox or warehouse TOML, construction wait, run_interactive vs session().
User guide Operator manual: scope, notes, structure documents, asking questions, migration, warmup, CSV upload validation, pitfalls — minimal code.
Integrator guide Embedding: suspend/terminal steps, reader/writer queue, multi-user deployment, observability.
Sandbox guide Bundled rental shop with mock LLM; same session API as production.
API reference Exported types, TOML schema, methods, document shapes, exceptions.
Troubleshooting Session outcomes, diagnostic codes, refusal catalogue, audit events.
Sandbox data reference Bundled rental-shop schema, federation topology, question corpus.
How it works Conceptual pipeline: schema build, storage, question phases, learning, write queue.
Security Threat model, LLM disclosure inventory, sensitivity tiers, deny lists.
Support matrix Per-engine capabilities, IR-unsupported constructs, dialect notes.

License

See LICENSE.

Release files for aetherdialect 0.2.3

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

Source distribution (sdist)

Source distribution for aetherdialect 0.2.3
File Size Uploaded
aetherdialect-0.2.3.tar.gz 2.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for aetherdialect 0.2.3
File Interpreter ABI Platform
aetherdialect-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 3.7 MB

Release files / aetherdialect-0.2.3.tar.gz

Download URL aetherdialect-0.2.3.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
011400e6f4114b45c64be6c2786316807bff6f1a8ed61e3dd3dc0090e2a8e41e
BLAKE2b-256 checksum
How to use checksums
5815dbb9654bf029aa88b6508320dbb69496be0e3caa6fa983575b683b696a16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / aetherdialect-0.2.3-py3-none-any.whl

Download URL aetherdialect-0.2.3-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
78aa235e4699b597878b9feb8206a29e181917df5f4a10f66afcf639e594a24e
BLAKE2b-256 checksum
How to use checksums
1a4ed3b9fb60681d2f825fa2239e5c26a8c32d488c271ae4fb781018b7b5591f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

0.2.4

2 release files

This release

0.2.3 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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