Turn natural language into SQL queries using LLMs (Google Gemini or OpenAI).
Ideal for databases where users don't know SQL but need insights fast!
- π£οΈ Ask database questions in plain English
- π€ Converts text β SQL using LLM
- π§ͺ Runs the query and shows actual results
- π‘οΈ Works with Google Gemini or OpenAI API
- π οΈ Easy to configure using
.envfile
- Python 3.9+
- A
.envfile with your API key:GOOGLE_API_KEY=your_google_api_key - Google Gemini access (Free, from: https://makersuite.google.com/app/apikey)
-
Clone this repository
git clone https://github.com/Thinkvas/text-sql-chatbot.git cd text-sql-chatbot -
Install dependencies
pip install -r requirements.txt
-
Set your API key
- Create a
.envfile using.env.exampleas template - Paste your Gemini or OpenAI key
- Create a
-
Run the chatbot
python app.py
Input:
Show me the total number of users who signed up in July.
Generated SQL:
SELECT COUNT(*) FROM users WHERE signup_date BETWEEN '2024-07-01' AND '2024-07-31';Result:
Total Users: 253
Pull requests are welcome! If youβd like to contribute, feel free to fork and improve.
MIT License β free for personal and commercial use.
Made by @Thinkvas π