Every text-to-SQL tool trusts the model to generate query. I built the opposite.
▲ 3 r/ClaudeMCP+2 crossposts

Every text-to-SQL tool trusts the model to generate query. I built the opposite.

LLMs shouldn't be writing your database queries.

That's the problem I've been trying to solve with QueryForge.

Instead of:

User → LLM → SQL/Mongo query → Database

QueryForge puts a structured layer in between:

User → LLM → QueryForge → validated query → Database

The idea is to separate understanding intent from actually constructing database queries.

Since my last post, QueryForge has grown quite a bit:

  • Java support
  • Python support
  • Go support
  • MCP support
  • MongoDB + MySQL + Postgres
  • Structured query AST
  • Query validation
  • Explicit error handling instead of silent failures

The MCP part is probably the most interesting addition for me.

It means QueryForge can sit between an AI agent and the database as a structured query layer rather than letting the agent directly generate database-specific syntax.

Curious: would you put a typed/validated query layer between an LLM and your database?

Docs & Example : https://queryforge-service.amtry.in

Github: https://github.com/awsaman-ai/queryforge

u/awsamanai — 8 days ago
▲ 12 r/DatabaseAdministators+2 crossposts

QueryForge – the LLM never writes the query, it fills in a typed AST

Hi everyone!

Over the past few months I've been building QueryForge, an open-source Go library that takes a different approach to natural language querying.

Most text-to-SQL systems ask an LLM to generate SQL directly.

The problem I kept running into was that, even with prompts and post-processing, the model could still invent columns, widen filters, or produce queries that were technically valid but not what the user intended.

So I flipped the architecture.

Instead of generating SQL, the LLM only fills in a typed Query AST.

Everything after that is deterministic Go:

Natural Language
        ↓
      LLM
        ↓
   Typed Query AST
        ↓
 AST Validation
        ↓
 SQL / Mongo Compiler

Some of the things this enables:

  • Unknown fields become validation errors with suggestions.
  • SQL injection isn't sanitized—it simply isn't representable in the AST.
  • DELETE/UPDATE operations don't exist in the AST.
  • Multi-tenant filters are injected after validation, so the model never even knows the tenant column exists.
  • The same AST can target multiple backends (currently PostgreSQL and MongoDB).

The core library uses only the Go standard library and is released under Apache-2.0.

I've also built a live demo where you can:

  • type natural language
  • inspect the generated AST
  • inspect the generated SQL
  • try invalid fields
  • try prompt injections
  • see how validation behaves

Live Demo
https://queryforge-demo.amtry.in

GitHub
https://github.com/awsaman-ai/queryforge

u/awsamanai — 12 days ago