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.
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
📖 Medium Article -> Never Write SQL Ever Again! 🤖Vanna.ai SQL AI Assistant Tutorial
Use Vanna.AI with OpenAI GPT-4o
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.
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.
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.
Open an issue, submit a pull request or contact me for any contributions.
Andrew Obando
Feel free to star ⭐ this repository if you find it helpful!

