DEV Community

retrovirusretro
retrovirusretro

Posted on

Chat with your database in plain English — locally, for free

"What were our top 10 customers last quarter by revenue, as a bar chart?"

DB-GPT translates that to SQL, runs it against your database, and renders the chart. No SQL knowledge required. Fully local. MIT licensed. 17K GitHub stars — almost no English content.


What is DB-GPT?

DB-GPT is an open-source framework that puts a natural language interface on top of your databases. You connect PostgreSQL, MySQL, SQLite, or others — then ask questions in plain English. It generates the SQL, executes it, and can visualize results automatically.

Think Metabase meets AI, but fully self-hosted and free.


Supported Databases

PostgreSQL · MySQL · MariaDB · SQLite · ClickHouse · DuckDB · Spark SQL


Setup

Clone the repo, copy .env.example to .env, add your database connection string, then docker compose up -d. Open localhost:5670admin / admin → Settings → Database → Add → paste connection string.

Full docker-compose: chinese-ai-tools-english-guide/tools/db-gpt


Example Queries

Once your database is connected:

  • "Show total sales by month for the last 12 months as a bar chart"
  • "Which products have inventory below 10 units?"
  • "Top 5 customers by order value with their email addresses"
  • "Average order fulfillment time grouped by warehouse"

DB-GPT generates SQL for each, runs it, returns results. Charts render automatically in the UI.


Connecting Ollama

Settings → LLM Provider → Ollama → Base URL: http://ollama:11434/v1 → Model: llama3

For best SQL accuracy use sqlcoder — fine-tuned specifically for SQL generation. Pull it with docker exec -it ollama ollama pull sqlcoder.


DB-GPT vs Vanna.ai

Both let you query databases with natural language:

DB-GPT Vanna.ai
License MIT MIT
Built-in UI ✅ Full app Minimal
Charts ✅ Built-in ❌ External
Visual pipeline ✅ AWEL
Self-hosted

DB-GPT if you want a complete self-contained app. Vanna.ai if you're embedding the capability programmatically into your own product.


n8n Automation

A ready-to-import workflow JSON is in the repo (integration/n8n-workflows/db-gpt-query.json). POST {question, db_name} → returns {answer, sql, data}.


Full Guide

chinese-ai-tools-english-guide

Previous articles in this series:


Your data never leaves your machine. No API keys, no cloud, no SQL knowledge needed.

Top comments (0)