Skip to content

shivansh023023/SQL-QUERY-GENERATOR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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
  1. Create a Virtual Environment (Optional but Recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  2. Install Dependencies:

    pip install -r requirements.txt
  3. 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"
  4. Run the App:

    streamlit run app.py

πŸ’‘ Usage

  1. Enter your request in plain English (e.g., "Get all employees who joined after 2020").
  2. Click on "Generate SQL Query".
  3. The app will display:
    • βœ… The SQL Query
    • πŸ“Š A sample output table
    • πŸ“ A simple explanation of the query

πŸ“· Screenshots

(Add screenshots of your app here)

πŸ“ Example

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;

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature-name)
  3. Commit your changes (git commit -m 'Add new feature')
  4. Push to the branch (git push origin feature-name)
  5. Open a Pull Request

πŸ“œ License

This project is licensed under the MIT License.

πŸ™Œ Acknowledgments


⭐ If you found this project helpful, feel free to star the repository! ⭐


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages