Vanna — Chat with Your SQL Database Using AI
AI-powered text-to-SQL. Ask questions in plain English, get accurate SQL queries and visualizations. Learns your schema. Works with any database. 23K+ stars.
Installation agent prête
Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.
npx -y tokrepo@latest install 695f1e28-3ca1-437a-b53e-cf9bdb86bd11 --target codexÀ exécuter après confirmation du plan en dry-run.
What it is
Vanna is an AI-powered text-to-SQL tool. You ask a question in plain English, and Vanna generates the correct SQL query, runs it against your database, and returns the results with optional visualizations. It learns your schema, table relationships, and query patterns to improve accuracy over time.
Vanna targets data analysts, business users, and developers who need quick answers from databases without writing SQL manually.
How it saves time or tokens
Vanna's training step lets it memorize your schema, column meanings, and example queries. Once trained, it generates accurate SQL on the first attempt rather than requiring iterative prompt engineering. This reduces both human time (no SQL writing) and token cost (fewer retries).
The visualization layer means you get charts directly from natural language without exporting to a BI tool.
How to use
- Install Vanna:
pip install vanna - Connect to your database (PostgreSQL, MySQL, SQLite, BigQuery, Snowflake)
- Train Vanna on your schema with DDL statements and example queries
- Ask questions in natural language and get SQL + results
Example
import vanna
from vanna.remote import VannaDefault
vn = VannaDefault(model='my-model', api_key='...')
vn.connect_to_postgres(
host='localhost',
dbname='analytics',
user='reader',
password='secret'
)
# Train on your schema
vn.train(ddl='CREATE TABLE orders (id INT, customer_id INT, total DECIMAL, created_at TIMESTAMP)')
vn.train(question='Total revenue last month', sql='SELECT SUM(total) FROM orders WHERE created_at >= DATE_TRUNC(\'month\', NOW()) - INTERVAL \'1 month\'')
# Ask questions
sql = vn.generate_sql('What are the top 10 customers by revenue?')
df = vn.run_sql(sql)
vn.generate_plotly_chart(df)
Related on TokRepo
- Database tools -- Database management and query tools
- RAG tools -- Retrieval-augmented generation pipelines
Common pitfalls
- Vanna accuracy depends heavily on training quality; provide representative DDL and at least 10-20 example question-SQL pairs
- Complex joins across many tables may produce incorrect queries; verify generated SQL before running on production data
- The default model uses Vanna's cloud API; for privacy, configure a local LLM backend
Questions fréquentes
Vanna supports PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, DuckDB, and any database accessible via SQLAlchemy. You connect using the appropriate connector method and Vanna handles the rest.
You train Vanna by providing DDL statements (CREATE TABLE), example question-SQL pairs, and documentation strings. Vanna stores these in a vector database and retrieves relevant context when generating SQL for new questions.
Yes. Vanna supports multiple LLM backends including OpenAI, Anthropic, Ollama, and any OpenAI-compatible endpoint. Configure the model parameter and API endpoint to use your preferred provider.
Accuracy depends on training quality. With good DDL coverage and 10-20 example queries, Vanna achieves high accuracy on typical analytical questions. Complex queries with subqueries or window functions may need more training examples.
Yes. After running a query, Vanna can generate Plotly charts from the result DataFrame. It selects appropriate chart types (bar, line, pie) based on the data shape and the original question.
Sources citées (3)
- Vanna GitHub— Vanna is an AI-powered text-to-SQL tool with 23K+ GitHub stars
- Vanna Docs— Vanna supports multiple database connectors and LLM backends
- arXiv— Text-to-SQL approaches for natural language database querying
En lien sur TokRepo
Source et remerciements
Created by Vanna AI. Licensed under MIT. vanna-ai/vanna — 23,000+ GitHub stars
Fil de discussion
Actifs similaires
Flatnotes — Self-Hosted Database-Free Markdown Notes
Flatnotes is a lightweight, self-hosted note-taking web app that stores notes as plain Markdown files in a flat folder — no database required, with full-text search and TOTP authentication.
SQLFluff — Modular SQL Linter and Auto-Formatter
A configurable SQL linter and formatter supporting over 20 SQL dialects, designed to enforce style rules and catch errors in data pipelines.
draw.io — Free Open-Source Diagramming Tool for Any Platform
draw.io is a free, browser-based diagramming application that supports flowcharts, UML, network diagrams, and more. Works offline as a desktop app on Windows, macOS, and Linux with no account required.
dbx — Lightweight Cross-Platform Database Client in 15 MB
A small, fast database client built with Tauri and Rust that connects to MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, ClickHouse, and SQL Server.