You can access the website at - https://sql-query-generator-lcmmrl3rurizsup225bez2.streamlit.app/
# π SQL Query Generator
A simple yet powerful web application that generates SQL queries from plain English prompts using **Google's Gemini Pro Model**. This tool also provides explanations and sample outputs for the generated SQL queries.
## π Features
- β
Convert natural language to SQL queries
- β
Get **sample outputs** for your SQL queries
- β
Simple and easy-to-understand **query explanations**
- β
Interactive UI built with **Streamlit**
## π οΈ Technologies Used
- **Python** - Core programming language
- **Streamlit** - For building the interactive web app
- **Google Generative AI (Gemini Pro)** - For generating SQL queries and explanations
- **HTML & Markdown** - Used within Streamlit for UI styling
- **SQL** - Generated as output queries
## π¦ Installation
1. **Clone the Repository:**
```bash
git clone https://github.com/your-username/sql-query-generator.git
cd sql-query-generator-
Create a Virtual Environment (Optional but Recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies:
pip install -r requirements.txt
-
Set Up Google API Key:
- Get your API key from Google Cloud Console.
- Replace the placeholder in the code with your API key:
GOOGLE_API_KEY = "YOUR_API_KEY_HERE"
-
Run the App:
streamlit run app.py
- Enter your request in plain English (e.g., "Get all employees who joined after 2020").
- Click on "Generate SQL Query".
- The app will display:
- β The SQL Query
- π A sample output table
- π A simple explanation of the query
(Add screenshots of your app here)
Input:
Show me the top 5 customers with the highest purchases in 2023.
Generated SQL:
SELECT customer_name, SUM(purchase_amount) AS total_purchases
FROM sales
WHERE YEAR(purchase_date) = 2023
GROUP BY customer_name
ORDER BY total_purchases DESC
LIMIT 5;- Fork the repository
- Create your feature branch (
git checkout -b feature-name) - Commit your changes (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature-name) - Open a Pull Request
This project is licensed under the MIT License.
β If you found this project helpful, feel free to star the repository! β