SQL Chat is an intelligent conversational interface that enables natural language interactions with MySQL databases. Built with Streamlit, LangChain, and ChatGroq, it transforms complex SQL queries into simple conversations, making database exploration accessible to users of all technical levels.
- Simple MySQL database connection through an intuitive UI
- Secure credential management
- Support for custom host, port, and database configurations
- Ask questions about your database in plain English
- Get responses in both SQL and natural language
- Maintains conversation context for more relevant answers
- Powered by ChatGroq's Mixtral-8x7b-32768 model
- Automatically generates optimized SQL queries
- Converts technical SQL results into human-readable responses
- Real-time query processing
- Persistent conversation history
- Clean and intuitive chat interface
- Clone the repository:
git clone https://github.com/yourusername/sql-chat.git
cd sql-chat
- Create and activate a virtual environment:
# For Unix/macOS
python3 -m venv venv
source venv/bin/activate
# For Windows
python -m venv venv
venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up your environment variables:
# Create .env file and add your Groq API key
echo "GROQ_API_KEY=your_api_key_here" > .env
streamlit==1.31.1
langchain==0.1.8
langchain-community==0.0.21
langchain-core==0.1.24
langchain-openai==0.0.6
mysql-connector-python==8.3.0
groq==0.4.2
langchain-groq==0.0.1
python-dotenv
- Start the application:
streamlit run app.py
-
Configure your database connection in the sidebar:
- Enter hostname (default: localhost)
- Specify port (default: 3306)
- Provide username and password
- Select database name
-
Click "Connect" to establish database connection
-
Start chatting with your database:
- Ask questions in natural language
- View SQL queries and their translations
- Explore your data through conversation
"Show me the top 5 customers by total orders"
"What was the average order value last month?"
"List all products that are out of stock"
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Database credentials are handled securely and not stored permanently
- Sensitive information is masked in the UI
- All database connections are session-specific
This project is licensed under the MIT License - see the LICENSE file for details.