AI SQL Query Generator · Postgres

Generate verified, read-only Postgres queries from plain English

A Postgres query generator that verifies before it returns: ask in plain English and get back a read-only SELECT that runs on your own Postgres, schema-profiled and capped at 1,000 rows, with the exact SQL shown under every answer. Free generators hand you a query and hope it's right; Chion verifies it before it returns, then lets you keep it as a portable SQL skill.

Chion verifies every query before it returns (schema profiling, a SQL contract, a two-layer validator, and a 1,000-row cap), schema-aware and read-only, with the source SQL auditable under every chart. Every verified query exports as a portable SQL skill.

Step 1 · Question
"Top 10 customers by revenue last quarter"
Step 2 · Verified SQL
SELECT c.company_name, SUM(o.total_amount) AS revenue FROM customers c JOIN orders o ON o.customer_id = c.customer_id WHERE o.order_date >= DATE_TRUNC('quarter', CURRENT_DATE - INTERVAL '3 months') GROUP BY c.company_name ORDER BY revenue DESC LIMIT 10;
Step 3 · Interactive chart

What is a SQL query generator?

A tool that converts plain-English questions into working SQL.

A SQL query generator is a tool that converts a plain-English question into a working SQL statement. Most generators stop at the text; Chion reads your database schema first, picks the right tables and joins, and validates the output before running it. You get a SELECT statement you can execute or paste into any PostgreSQL client. No syntax knowledge required. Unlike a drag-and-drop Postgres query builder, a generator writes the SQL from the question itself; you review the SELECT instead of assembling it.

Related tools: conversational analytics · connect Chion to PostgreSQL.

Example: Top 10 customers by revenue

A real question, the generated SQL, and the verified output.

Question: "Who are our top 10 customers by revenue last quarter?"

SELECT
  c.customer_id,
  c.company_name,
  SUM(o.total_amount) AS revenue
FROM customers c
JOIN orders o ON o.customer_id = c.customer_id
WHERE o.order_date >= DATE_TRUNC('quarter', CURRENT_DATE - INTERVAL '3 months')
  AND o.order_date <  DATE_TRUNC('quarter', CURRENT_DATE)
GROUP BY c.customer_id, c.company_name
ORDER BY revenue DESC
LIMIT 10;

Generated by Chion's 13-step pipeline. Read-only SELECT, LIMIT enforced, schema-validated.

Generate a SQL query in 13 steps

From question to verified PostgreSQL, handled by Chion's pipeline.

Type your question, Chion profiles your schema, builds a SQL contract, generates SQL inside that contract, validates it through L1 (read-only) and L2 (runtime lint), runs it read-only with LIMIT enforced, and renders the chart. Every step is auditable.

See the 13-step verified SQL pipeline

Each question routes to the right SQL shape before a single line is written

Three example strategies: top-K ranking, comparison, and entity lookup.

Ask "top 10 customers by revenue" and you get TopK ranking, which picks a different SQL shape than "compare revenue by region over time," which routes to comparison. The strategy determines the query structure before the model writes anything.

  • entity_lookup
  • comparison
  • topk_ranked
  • extrema_detection
  • dimension_breakdown
  • universal_quantifier
  • time_bounded_only

Explore the pipeline

Hover or tap any node to see how it works

7

Strategies

We read your database first, so the SQL fits your tables, not a guessed schema

We read your database before writing a single query.

Before the LLM sees anything, Chion runs a profiling pass against your database. Every table, every column, every data type, every cardinality, cataloged. Value samples are collected so the system knows what "Acme Corp" or "Q3 2024" actually looks like in your data.

Each column gets classified as temporal, quantitative, categorical, or identifier. This classification drives which aggregations are valid, which columns get grouped, and which columns get filtered. Entity resolution uses pgvector embeddings to match your words to actual column values.

Every query is verified before it runs. DELETE and DROP can't be emitted

Two-layer validation: L1 read-only check, L2 runtime lint.

L1: Pre-validation (read-only check)

Blocks anything that isn't a SELECT. INSERT, UPDATE, DELETE, DROP, ALTER are rejected at the contract level, in code, not in the LLM.

L2: Runtime lint (mode-based validation)

SELECT * is blocked. LIMIT is enforced. JOIN conditions are validated against the schema profile. Columns must be explicit.

Row budget truncation

Row budget truncation enforced at adapter level (≤1,000 rows / 12,000 cells). If results are truncated, the chart discloses it.

Read-only SELECT. AES-256-GCM credential vault. 1,000-row cap. Immutable audit log. Read the full security model →

See three SQL query examples, verified.

Three plain-English questions and the verified PostgreSQL Chion generates.

A ranking query, a multi-CTE ratio, and a window-function running total: three of the most common patterns Chion generates.

"Top 10 customers by revenue last quarter"

JOIN + GROUP BY + LIMIT
SELECT
  c.customer_id,
  c.company_name,
  SUM(o.total_amount) AS revenue
FROM customers c
JOIN orders o ON o.customer_id = c.customer_id
WHERE o.order_date >= DATE_TRUNC('quarter', CURRENT_DATE - INTERVAL '3 months')
  AND o.order_date < DATE_TRUNC('quarter', CURRENT_DATE)
GROUP BY c.customer_id, c.company_name
ORDER BY revenue DESC
LIMIT 10;

"Churn rate month over month"

CTE + ratio
WITH monthly AS (
  SELECT
    DATE_TRUNC('month', canceled_at) AS month,
    COUNT(*) AS churned
  FROM subscriptions
  WHERE canceled_at IS NOT NULL
  GROUP BY 1
),
active AS (
  SELECT
    DATE_TRUNC('month', period_start) AS month,
    COUNT(DISTINCT user_id) AS active
  FROM subscriptions
  GROUP BY 1
)
SELECT
  m.month,
  m.churned,
  a.active,
  ROUND(m.churned::numeric / NULLIF(a.active, 0) * 100, 1) AS churn_rate_pct
FROM monthly m
JOIN active a ON a.month = m.month
ORDER BY m.month;

"Running total of revenue by week"

CTE + SUM OVER
WITH weekly AS (
  SELECT DATE_TRUNC('week', order_date) AS week, SUM(amount) AS revenue
  FROM orders GROUP BY 1
)
SELECT
  week,
  revenue,
  SUM(revenue) OVER (ORDER BY week) AS running_total
FROM weekly
ORDER BY week;

Keep every verified query as a portable SQL skill, not a one-off you regenerate

A generator gives you a query. Chion gives you a library that compounds.

A standalone SQL query generator gives you a query: one off, ad-hoc, regenerated next time you ask. Chion promotes each verified query into a per-persona SQL skill library, scoped to the persona that owns the data. Finance personas inherit revenue queries; ops personas inherit logistics queries. The library compounds with every question your team asks.

Chion vs other text-to-SQL tools

Free text-to-SQL boxes guess against a pasted schema. Chion verifies against your live one.

FeatureChionAskYourDatabaseVannaJuliusTextQL
Routes to a verified-query library (vs. generates fresh SQL each turn)
Auto-generated query library that compounds (vs. none; every query fresh-generated)
Portable AI agent file: CHION.md → Claude Code, Codex, Cursor (vs. locked to vendor UI)
Two-layer validator + typed SQL contract (vs. free-form SQL execution)
Read-only SELECT enforced in code (not LLM instruction)Not documented
SQL visible under every chartNot documented
AES-256-GCM credential vaultNot documented
Schema profiling before generationNot documented
Auto-repair loop on contract violationNot documented
Row budget enforced (1,000 rows / 12,000 cells)Not documented
Interactive D3 charts auto-selected by column typeAuto-updating dashboards
Grounded narrative per chartNot documented
Starting price per seat$29/mo$19/moFree OSS / $200 cloud$20/moNot public (enterprise)
Trial available7-dayNot public

Competitor values verified from public product pages at time of writing (TextQL cells from textql.com; "Not documented" means the capability is absent from its public pages, not disproven). Chion routes to queries your team already verified; most text-to-SQL tools regenerate fresh SQL every turn. Correct a cell by opening a PR against src/data/comparisons.ts.

Compare Chion vs text-to-SQL tools →

Have a question we haven't answered?

Browse all 89 questions in one place: security, pricing, comparisons, and how the pipeline works.

Visit the full FAQ

Start generating verified SQL

Connect your PostgreSQL database and ask your first question in plain English.