A Streamlit-powered AI application that allows you to chat with your SQL database using natural language. Instead of writing SQL queries manually, you can simply ask questions like:
“Show the top 5 tracks by sales.” “List all customers from Germany.” “Which artist has the most albums?”
The app converts your question into SQL using an LLM and returns the results instantly.
🚀 Natural Language → SQL Ask questions in plain English and get results from your database.
🗄 Multiple Database Support
- Cloud SQLite database
- Local MySQL database
🤖 Powered by AI
- Uses LangChain + OpenAI GPT-4o for intelligent SQL generation.
📊 Interactive UI
- Built with Streamlit for an intuitive chat interface.
🔍 Automatic Schema Understanding
- The model analyzes database tables and generates correct SQL queries.
The app follows a clean pipeline architecture:
User Question
↓
LLM generates SQL query
↓
SQL query executed on database
↓
Results returned to the user
This avoids common SQL-agent issues like:
- parsing errors
- infinite loops
- markdown formatting problems
- 🧠 LangChain
- 🤖 OpenAI GPT-4o
- 🌐 Streamlit
- 🗄 SQLite / MySQL
- 🐍 Python
Chat_SQL
│
├── app.py # Main Streamlit application
├── requirements.txt # Python dependencies
├── README.md # Project documentation
git clone https://github.com/siddhartharishi/Chat_SQL.git
cd Chat_SQLpython -m venv venv
source venv/bin/activateWindows:
venv\Scripts\activatepip install -r requirements.txtCreate an API key from 👉 https://platform.openai.com
Run the app and enter the key in the sidebar.
streamlit run app.pyThen open:
http://localhost:8501
You can ask questions like:
Show the top 5 tracks by sales
List all customers from Canada
Which artist has the most albums
What are the most popular genres
Provide a downloadable .db URL.
Example:
https://storage.googleapis.com/benchmarks-artifacts/chinook/Chinook.db
Enter:
- Host
- Username
- Password
- Database name
