Read-only access
Queries run on a replica with a read-only user. No accidental UPDATEs.
A text-to-SQL assistant translates plain questions into queries on a read-only copy of your data, shows the query, and explains the result.
{
}
-- Q: Top 5 products by revenue last month?
SELECT p.name, SUM(l.price_subtotal) AS revenue
FROM sale_order_line l
JOIN product_product pp ON pp.id = l.product_id
JOIN product_template p ON p.id = pp.product_tmpl_id
JOIN sale_order o ON o.id = l.order_id
WHERE o.state = 'sale'
AND o.date_order >= date_trunc('month', now()) - interval '1 month'
AND o.date_order < date_trunc('month', now())
GROUP BY p.name
ORDER BY revenue DESC
LIMIT 5;Queries run on a replica with a read-only user. No accidental UPDATEs.
'Revenue' means the same thing in every answer because it's defined once.
Analysts can check, copy, and reuse the generated SQL.
Users only see data their role allows.
Dashboards answer the questions someone thought of in advance. The rest, such as which customers bought less this quarter or what share of returns came from one supplier, land on an analyst's desk, wait in a queue, and arrive days later. Many never get asked at all.
Text-to-SQL assistants let people ask those questions directly in plain language. The assistant translates the question into a database query, runs it against a safe copy of the data, and shows the result along with the query it used. Analysts stay in control because every answer is inspectable and reusable.
The difference between a toy and a trustworthy assistant is the semantic layer: agreed definitions of revenue, margin, active customer, and the rest. Without it, the model guesses, and two people asking the same question can get two different numbers.
Business terms mapped to tables, joins, and filters once, then reused by every answer.
The assistant sees curated table descriptions, not the raw database, which reduces wrong joins.
Every answer shows the query, so analysts can verify and reuse it.
Real questions with known answers test the assistant whenever the schema or prompts change.
Queries never touch production writes and can't slow down operations.
Row-level rules keep each user to the data their role allows.
| Type | Example | Fit |
|---|---|---|
| Lookups and totals | Revenue by region last quarter | Strong |
| Rankings and trends | Top ten customers by margin this year | Strong |
| Comparisons | This month versus the same month last year | Strong with a semantic layer |
| Multi-step analysis | Which churned customers had support tickets first | Good, with review of the SQL |
| Judgment questions | Why did sales drop? | Limited: it can show data, not causes |
Step 01
Start with one area, such as sales or inventory, with a clear owner.
Step 02
Agree definitions with finance and operations and encode them.
Step 03
Connect the read replica, build the assistant, and score it on real questions.
Step 04
Release to a small group of power users and refine from their questions.
The first pitfall is pointing an assistant at a raw database and hoping for the best. Without curated table descriptions and metric definitions, it guesses joins and filters, and confident wrong numbers erode trust fast.
The second is answering questions nobody can verify. Showing the SQL, the filters used, and the time period on every answer lets analysts and managers check the logic rather than take it on faith.
The third is launching to everyone at once. A pilot with power users surfaces the questions that confuse the assistant, so the semantic layer can be improved before a wider rollout.
| Measure | Why it matters |
|---|---|
| Answer accuracy | Correct results on the evaluation set of real questions |
| Clarification rate | How often the assistant asks for more detail instead of guessing |
| Time to answer | From question to result, compared with an analyst request |
| Repeat usage | Whether people come back, which shows real value |
Picture a sales director who wants to know which product categories grew fastest in one region compared with last year. Today that means an email to an analyst and a wait. With a conversational assistant, the director asks the question directly and gets a table, a simple chart, and the SQL used.
If the director then asks for the same view by salesperson, the assistant reuses the context. The analyst reviews a sample of answers each week and improves the metric definitions where questions were misread.
Success is people answering their own everyday data questions in seconds, analysts freed for deeper work, and numbers that match the official reports because they use the same definitions. Accuracy on the evaluation set stays high as new questions are added.
A system that turns questions into database queries needs firm limits. OWASP's guidance on excessive agency recommends limiting permissions to the minimum necessary, including read-only database roles where writes aren't neededSource [1]. Our conversational BI uses read-only access to a reporting replica, scoped to what each user may see.
Prompt injection, OWASP's top LLM risk, includes instructions hidden in data the model processesSource [2]. Showing the generated query alongside every answer lets people check the logic, and validating queries in code before they run stops anything outside the allowed shape.
RAG knowledge systems
Retrieval-augmented generation over your documents: permission-aware search, cited answers, vector databases, and evaluation.
DevOpsPostgreSQL HA
PostgreSQL high availability: streaming replication, read replicas, automatic failover, connection pooling, and tested backups.
AIAI security & governance
Deploy AI safely: private model hosting, data minimization, access controls, prompt-injection defenses, audit logs, and usage policies.
Next step
Thirty minutes with an engineer, no slide deck required. You'll leave with a clearer picture, whether or not we work together.