AI SQL Query Generator · Postgres

A Postgres SQL query generator that shows each query it ran.

Most generators draft against a schema you paste in. Chion writes against the schema of the database you connect, checks the statement in code before it runs, and executes it under the read-only role you supply, capped at 1,000 rows. You read the SELECT that ran, or the reason it was rejected. Code-validated is not the same as correct: the check covers read-only shape, not your business definitions.

7-day trial. Connect a read-only PostgreSQL role.

Chion profiles your schema, binds the question to a typed SQL contract, runs a two-layer read-only check, and caps the result at 1,000 rows. The statement that produced a chart stays on the page beside it. A query a person reviews and promotes compiles into a portable SQL skill.

Step 1 · Question
"Top 10 customers by revenue last quarter"
Step 2 · Code-validated 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 code-validated 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 code-validated 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 code-validated SQL pipeline

Questions are routed before any SQL 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

SQL that 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 checked in code before it runs.

DELETE and DROP can't be emitted. Two-layer validation: L1 read-only check, L2 runtime lint.

Read-only check before it runs

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

Second check as it runs

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

Results capped at 1,000 rows

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

Read-only SELECT. Credentials in an AES-256-GCM vault. Results capped at 1,000 rows. Each executed query leaves an audit row, written fire-and-forget so a logging failure never blocks your answer. Read the full security model →

See three SQL query examples.

Three plain-English questions and the code-validated 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 reviewed query as a reusable skill.

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 compiles each query your team saved and reviewed into a portable SQL skill library, scoped to the role that owns the data. A finance role inherits revenue queries; an ops role inherits 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 validates against your live one.

FeatureChionVannaJuliusTextQLText2SQL.ai
Read-only execution policyNon-optional: SELECT only, checked in code before executionPermission hooks in a framework with hosted and self-hosted pathsDedicated read-only database credentials recommendedNot publicly documentedSafe Mode blocks modification and administrative statements, on by default, disableable per connection or API request
Published result caps1,000 rows and 12,000 cells per resultNot publicly documentedNot publicly documentedNot publicly documentedNot publicly documented
Where reusable query logic livesSaved queries in Chion, compiled to CHION.md or SKILL.md for Claude Code and CodexNot publicly documentedNot publicly documentedOntology 3.0 definitions, queries, permissions, and artifacts in a Git repository you own, with bidirectional syncNot publicly documented
Generated code shown to the userThe executed SELECT, shown with the chart and the narrativeNot publicly documentedGenerated SQL or Python, shown and editableNot publicly documentedNot publicly documented
Source availability and hostingManaged serviceMIT-licensed, with hosted and self-hosted paths documentedNot publicly documentedNot publicly documentedCloud, plus a desktop app that keeps credentials local and sends schema names rather than rows
Published pricing model$29, $99, or $299 per seat per month; Enterprise per team, custom-quotedFree MIT-licensed source, alongside a published commercial pricing pagePublished per-plan pricingCompute-based and custom tiersNot publicly documented

Every competitor cell traces to that vendor’s own documentation, checked 2026-08-31. Vanna: github.com/vanna-ai/vanna and vanna.ai/pricing (the GitHub repository has been archived and read-only since 2026-03-29; the commercial pricing page is still published). Julius: julius.ai/docs/data-connectors/overview, /data-connectors/postgres, /get-started/creating-custom-visualizations, and julius.ai/pricing. TextQL: textql.com/products/ana, textql.com/products/ontology, and textql.com/pricing. Text2SQL.ai: text2sql.ai/docs/security-measures, text2sql.ai/desktop, and text2sql.ai/docs/connections. "Not publicly documented" means the dimension is absent from the sources listed for that product on that date, not that the capability is missing. 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 90 questions in one place: security, pricing, comparisons, and how the pipeline works.

Visit the full FAQ

Generate a read-only SELECT against your schema

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