Skip to content

Using Vanna AI to generate SQL queries from a local MySQL database

License

Notifications You must be signed in to change notification settings

Azie88/Vanna-SQL-AI-Assistant

Repository files navigation

Vanna-SQL-AI-Assistant

VANNA.AI Logo

Automating SQL Query Generation with Vanna.AI

This repository contains a tutorial on using Vanna.AI to generate SQL queries from a local MySQL database.

What is Vanna.AI? 🤖

Vanna.AI is an open-source AI tool designed to translate natural language queries into SQL for seamless database interactions. It supports multiple databases, including MySQL, PostgreSQL, Snowflake, and more. With Vanna.AI, users can quickly generate SQL queries without needing in-depth SQL knowledge.

📖 Official Vanna.AI Documentation -> Vanna.AI Docs

🗄️Github Repository -> Vanna.AI

Project Links 📑

📖 Medium Article -> Never Write SQL Ever Again! 🤖Vanna.ai SQL AI Assistant Tutorial

Vanna.AI Demo

Use Vanna.AI Free

Use Vanna.AI with OpenAI GPT-4o

Get started 🏁

1️⃣ You need to have Python 3 on your system.

2️⃣ Clone this repository: git clone https://github.com/Azie88/Vanna-SQL-AI-Assistant.git

3️⃣ On your IDE, create A Virtual Environment and Install the required packages for the project:

  • Windows:

      python -m venv venv; 
      venv\Scripts\activate; 
      python -m pip install -q --upgrade pip; 
      python -m pip install -qr requirements.txt  
    
  • Linux & MacOs:

      python3 -m venv venv; 
      source venv/bin/activate; 
      python -m pip install -q --upgrade pip; 
      python -m pip install -qr requirements.txt  
    

NB: For MacOs users, please install Xcode if you have an issue.

4️⃣ Sign up and Generate an API Key on Vanna.ai

5️⃣ Set up a .env file in the project root and store your api key

    vanna_api_key=your_api_key_here

6️⃣ Run the Vanna_AI_Starter.py to use vanna with the default sample database.

Vanna Web App Demo

Use Vanna.ai free with local SQL database

Run the Vanna_Hosted.ipynb notebook and follow the steps. Make sure you have a MySQL database and are running the MySQL server. Find out how to create one here

Alternatively, you can connect any database of your own. Visit the Vanna.ai for instructions. Edit the code with your own database connection and training.

Use Vanna.ai with OPENAI API

Create an OPENAI API Key and run the Vanna_OpenAI.ipynb notebook to follow the steps. Edit the code with your own database connection and training.

Contributions 🤝

Open an issue, submit a pull request or contact me for any contributions.

Author ✍️

Andrew Obando

Andrew Obando | LinkedIn Medium


Feel free to star ⭐ this repository if you find it helpful!

About

Using Vanna AI to generate SQL queries from a local MySQL database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published