A powerful, interactive SQL chatbot built using LangChain, Streamlit, and Groq LLaMA3 models. This tool enables users to communicate with relational databases (SQLite or MySQL) using natural language queries. Ideal for data analysts, developers, or educators who want a hands-free way to explore and interact with their databases.
- 🔗 Connects to both SQLite and MySQL databases.
- 💬 Enables natural language querying using Groq's LLaMA3-8B model.
- 🧠 Uses LangChain's SQL agent and toolkits for dynamic SQL generation.
- 🖥️ Simple and elegant UI with Streamlit.
- 🔒 API key secured access and configurable MySQL credentials.
LangChain-SQLChatAgent/
├── app.py # Main Streamlit application
├── sqlite.py # Script to create and populate a sample SQLite DB
├── student.db # SQLite database file (auto-generated)
├── requirements.txt # Python dependencies
├── assets/
│ ├── screenshot.png # Demo screenshot
│ └── social-preview.png # GitHub social preview banner
└── README.md # This filegit clone https://github.com/Electrolight123/LangChain-SQLChatAgent.git
cd LangChain-SQLChatAgentpip install -r requirements.txtpython sqlite.pystreamlit run app.pyYou'll need a Groq API key to use the LLaMA3 model. You can get one from Groq Cloud. Paste it into the sidebar input field when prompted in the app.
If you want to use your own MySQL database:
- Choose "Connect to your MySQL Database" in the sidebar.
- Provide:
- Host
- Username
- Password
- Database name Make sure your DB is accessible and contains some data for querying.
- "List all students who scored more than 80."
- "How many students are in Data Science class?"
- "Show names of students in section A."
langchain
langchain_groq
streamlit
sqlalchemy
mysql-connector-python
python-dotenv
validators
- ✅ Add PostgreSQL support
- ✅ Add file upload for SQL dumps
- ✅ Improve response formatting
- ✅ Add export options for query results
This project is licensed under the MIT License.
Abhishek Bala B.Tech & M.tech @ NIT Rourkela Feel free to connect on LinkedIn or check out more at GitHub
If you find this project useful, consider giving it a ⭐ and sharing it with your network!

