Skills2026年3月31日·1 分钟阅读

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.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Vanna — Chat with Your SQL Database Using AI
直接安装命令
npx -y tokrepo@latest install 695f1e28-3ca1-437a-b53e-cf9bdb86bd11 --target codex

先 dry-run 确认安装计划,再运行此命令。

TL;DR
Vanna converts natural language questions into accurate SQL queries and visualizations.
§01

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.

§02

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.

§03

How to use

  1. Install Vanna: pip install vanna
  2. Connect to your database (PostgreSQL, MySQL, SQLite, BigQuery, Snowflake)
  3. Train Vanna on your schema with DDL statements and example queries
  4. Ask questions in natural language and get SQL + results
§04

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)
§05

Related on TokRepo

§06

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

常见问题

Which databases does Vanna support?+

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.

How does Vanna learn my schema?+

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.

Can I use Vanna with a local LLM?+

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.

How accurate is the generated SQL?+

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.

Does Vanna handle data visualization?+

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.

引用来源 (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
🙏

来源与感谢

Created by Vanna AI. Licensed under MIT. vanna-ai/vanna — 23,000+ GitHub stars

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产