Business Problem
The client's business analysts depended on the IT department for ad-hoc data requests: someone had to write the query, pull the data and build the chart. The client asked us for a tool that lets analysts ask questions of the company's databases in plain language, get the data and turn it into charts themselves, with database information kept up to date.
Solution
We built a data and reporting assistant for business analysts. An analyst asks a question in plain language, the assistant writes and runs the query against the right database, and then generates the code for a chart or dashboard from the result. Analysts can answer more of their own questions, and IT spends less time on routine data pulls.
Features
- On-the-fly translation of plain-language questions into database queries (SQL for MS SQL, PostgreSQL and AWS Redshift, and MongoDB queries)
- Query execution on a selected schema
- A Python code generator that turns the final data set into a web dashboard or chart
- Slack integration, with deployment to AWS or Azure

How It Works
The assistant is available as a chatbot in Slack and as a web application. Analysts ask questions in plain language and run queries against different databases from whichever of the two they prefer.
Once the data set is ready, the application generates Python code with standard charting libraries. The code builds a web dashboard with charts, time series plots and graphs.
Large language models, OpenAI GPT models and open-source models, also check the generated Python code. When the code fails, the error goes back to the model for a fix before the analyst sees the result.
To build a query, the application finds the relevant database schema for the question using table definitions (DDL) stored in a vector database. A Python pipeline refreshes the schema and table definitions on a schedule, so the assistant works from the current structure of each database.
Business Value
Analysts get answers to ad-hoc questions without waiting in the IT queue, and they can look at the query behind a chart to check where the numbers come from. We ran the project end to end, from discovery and a proof of concept (POC) to the final product.
How We Build Text-to-SQL Assistants
An analyst's question in plain language has to become a correct query against a real schema, then a correct chart. Each of those steps can fail quietly, so we build the assistant as a chain of small, checked steps:
- Schema knowledge. Table definitions, column descriptions, sample values and approved example queries are indexed and kept in sync with the databases. Business terms, such as how a metric is defined, are stored next to the tables they refer to.
- Schema selection. For each question, retrieval over PostgreSQL with pgvector or a vector database picks the few tables that matter, so the model is not given the whole warehouse.
- Query generation. The model writes SQL for the specific dialect. The query is parsed, checked against the schema and run read-only with row and time limits.
- Repair. Errors and empty results go back to the model with the failing query. After a fixed number of attempts the assistant asks the user to clarify.
- Visualization. Chart code is generated from the result set and run in a sandbox. The SQL is always shown next to the chart.
Today we build this as a LangGraph workflow with LangSmith tracing and evaluation, and give the model database access through MCP tools with read-only permissions. The web client is a TypeScript application with Next.js and Node.js.
Why Text-to-SQL Is Harder Than Benchmarks Suggest
A query that runs is not the same as a query that is right. The most dangerous result is a valid query with the wrong join or the wrong date filter, which returns a plausible number. Real warehouses make this likely: hundreds of tables, similar column names, and metrics whose definition lives in someone's head.
Benchmarks show the gap between clean and real schemas. In Spider 2.0, a benchmark built on enterprise text-to-SQL workflows, an agent based on a strong reasoning model solved only 21.3% of tasks, compared with 91.2% on the earlier Spider 1.0 and 73.0% on BIRD.
We handle this with evaluation on the client's own data. A test set of real questions with verified answers runs on every change to prompts, schema metadata or model. Results are compared by value, not by SQL text. Ambiguous questions get a clarifying question instead of a guess, and every answer shows the SQL so an analyst can check it. More on our approach: AI agent development and natural language processing services.
database engines supported: MS SQL, PostgreSQL, AWS Redshift, MongoDB
project timeline
specialists on the team