An open-source text-to-SQL AI agent that converts natural language into safe SQL, with production deployment patterns for Databricks, Snowflake, and AWS Lambda. Schema-aware prompt engineering, SQL safety guardrails (SELECT-only validation), and three reference implementations you can deploy at work.
Featured In
- AAAI-25 Workshop on Open-Source AI for Mainstream Use (Philadelphia, March 2025) — DB Agent presented as a reference implementation for production text-to-SQL agents. Workshop program · Paper
DB Agent is a minimal natural-language-to-SQL system. A user asks a question in plain English; DB Agent retrieves relevant schema context, prompts an LLM to generate a SQL query, validates the query against a SELECT-only safety layer, executes it against the target database, and returns the results with every intermediate step visible. It ships with two reference deployments — a generic Streamlit app and a native Databricks App with Unity Catalog integration — so teams can pick the pattern that matches their environment.
- Text-to-SQL — natural language to SELECT queries via any LLM
- Safety layer — blocks all write/admin SQL before it reaches the database
- Explainability — schema context, generated SQL, and validation all visible
- Any OpenAI-compatible LLM — OpenAI, GitHub Models, Groq, Ollama, LM Studio
- Any SQL database — SQLite by default; PostgreSQL, MySQL, Lakebase, Unity Catalog via one env var
- Agentic Memory — Cross agent memory and context awareness to suggest queries, best usecase OLTP, OLAP
The primary implementation is the Node.js/React app in nodejs-app/ — spin it up locally in one command, or deploy it straight to Databricks Apps.
Run it locally (SQLite + local Ollama, no API key needed):
cd nodejs-app
ollama pull qwen2.5-coder:7b
./run_local.shOpen http://localhost:3001. Any OpenAI-compatible endpoint works instead of Ollama — see nodejs-app/.env.example for OpenAI, Groq, and Databricks Model Serving.
Deploy to Databricks Apps:
cd nodejs-app
databricks apps create db-agent-node --description "DB Agent"
databricks sync . /Workspace/Users/<you>/db-agent-node \
--exclude "node_modules/**" --exclude "web/node_modules/**" --exclude "web/dist/**"
databricks apps deploy db-agent-node --source-code-path /Workspace/Users/<you>/db-agent-nodeDatabricks installs dependencies and builds the frontend automatically. See nodejs-app/README.md for app.yaml configuration (LLM endpoint, secrets, embeddings model for the memory feature).
An earlier Python/Streamlit implementation is preserved under legacy/streamlit-app/ for reference — see its README for how to run it.
New to AI agents? Work through the modules in order — each one builds on the last:
| Module | Concept | What you build |
|---|---|---|
| 01 — LLM Basics | What is an LLM API call? | Notebook: raw API call, messages, temperature |
| 02 — Structured Output | How to get reliable JSON from an LLM | Notebook: JSON mode + Pydantic validation |
| 03 — Tool Use | LLM calls functions instead of generating text | Agent that decides when to query the DB |
| 04 — Agentic Loop | Retry, reflect, recover from errors | Agent with max-steps guard and error recovery |
| 05 — MCP Server | Expose tools via a standard protocol | MCP server connectable to Claude Desktop |
The team behind DB Agent teaches production text-to-SQL and Databricks patterns through hands-on bootcamps.
- Private team workshops — Virtual workshops on AI Agents, Claude Code, MS Copilot, text-to-SQL agents, SQL safety guardrails, and Databricks deployment patterns. Contact BeCloudReady (Databricks Registered Partner).
Community: TorontoAI — 10,000+ data and AI practitioners across Toronto, the GTA, and the US East Coast.
BeCloudReady — Databricks Registered Partner. Organizers of TorontoAI.
Book a discovery call for Customized training/consulting engagement