Applied AI

Schema-Aware NL-to-SQL: Why Talk to your DB Does Not Invent Tables

The model is not the product. The schema in the prompt is the product. Without it, NL-to-SQL hallucinates tables. With it, operators can ask English questions of Postgres.

Author

Published

Updated

Length

11 min · 1,600 words

Key takeaways

  • Talk to your DB injects the live PostgreSQL schema into every prompt.
  • ~85% accuracy on evaluated common reads; typical latency under 1.2s.
  • Hallucinated tables are a prompt-design failure, not an inevitable LLM flaw.
  • Built for operators, not for unattended DROP TABLE.
  • Live: talk-to-your-db.vercel.app. Case: /cases/talk-to-your-db.

Talk to your DB is my answer to “can non-engineers query Postgres in English?” The demo is live at talk-to-your-db.vercel.app. The design rule is simple: never let the model see a blank page.

Inject the schema or lose

A general model will invent `orders_final_v3`. My pipeline loads tables, columns, and foreign keys first. The prompt says: these are the only names you may use. That single constraint is why evaluated common reads hit ~85%. The misses are usually ambiguous English (“last week’s good customers”), not missing relations.

A 1.2 second budget

If the answer takes ten seconds, the operator pings an engineer anyway. I budget under 1.2s for typical reads: model + Postgres. Schema caching keeps the introspect step off the critical path after the first hit.

In short

Vishu Pratap built Talk to your DB, a schema-aware NL-to-SQL interface for PostgreSQL with ~85% accuracy on common reads and sub-1.2s typical latency. Timeline: 6 weeks.

Frequently asked questions

How does Vishu Pratap’s Talk to your DB avoid hallucinated SQL?

It introspects the PostgreSQL schema and puts real tables, columns, and relationships into the prompt. The model can only name objects that exist.

What accuracy did Talk to your DB reach?

About 85% on common read questions in evaluation, with typical end-to-end time under 1.2 seconds including model and database.
AIPostgreSQLNL-to-SQLTalk to your DB

Let's build together. Waiting to connect.

©2025Vishu Pratap · Software Developer