Skip to content

An NLP-powered tool that uses Gemini 1.5 Flash to convert natural language queries into accurate SQL statements. It empowers non-technical users to interact with databases using plain English, eliminating the need to write SQL manually.

License

Notifications You must be signed in to change notification settings

DevWaqarAhmad/NL-to-SQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 SQL Query Generator Assistant

Python Streamlit License: MIT

An AI-powered chatbot built using Streamlit, Gemini API, and LangChain that helps users convert natural language questions into valid SQL queries. Just upload your CSV or Excel file, describe your query in plain English, and get instant SQL output!


🚀 Features

  • 🗣️ Natural Language to SQL: Just ask questions like:
    • "Show all students with grade A"
    • "Get the total sales for June"
  • 📂 Upload Your Own Data: Supports .csv and .xlsx files
  • 🤖 AI-Powered Responses: Uses Google’s Gemini model (via LangChain)
  • 🧠 Chat Memory: Remembers your name and conversation context
  • 📝 Conversation Summarizer: Generates a quick summary of your past chat
  • 🔄 Refresh Chat: Easily reset the conversation with one click
  • 📎 Schema-Aware SQL Generation: Automatically adapts SQL to your uploaded dataset

🛠️ Tech Stack


📁 Project Structure

├── app.py # Streamlit UI code ├── backend.py # NLP to SQL logic with LangChain & Gemini ├── .env # Environment variables (API keys) ├── requirements.txt # Python dependencies └── README.md # You're here!


✅ How to Run Locally

  1. Clone the Repo
    git clone https://github.com/DevWaqarAhmad/sql-query-assistant.git
    cd sql-query-assistant
    

pip install -r requirements.txt

GEMINI_API_KEY=your_google_gemini_api_key

streamlit run app.py 🧪 Example Queries Question Generated SQL Show all employees with salary > 5000 SELECT * FROM your_table WHERE salary > 5000; Count the number of students SELECT COUNT(*) FROM your_table; Get average marks SELECT AVG(marks) FROM your_table;

📬 Contact 📧 Email: devwaqarahmad@gmail.com

💡 Credits Built with by Waqar Ahmad Powered by Google Gemini API + LangChain

Let me know if you'd like GitHub repo badge, deployment badge (like Render, Vercel), or anything else added.

About

An NLP-powered tool that uses Gemini 1.5 Flash to convert natural language queries into accurate SQL statements. It empowers non-technical users to interact with databases using plain English, eliminating the need to write SQL manually.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages