A comprehensive SQL learning and analytics platform that combines natural language database querying, AI-powered explanations, visual analytics, and complete learning resources. Built with Streamlit, LangChain, and supporting both OpenAI and Groq APIs.
• Multiple Database Support: SQLite, MySQL, and custom database creation
• Natural Language Querying: Ask questions about your data in plain English
• AI-Powered SQL Generation: Automatic SQL query generation and execution
• Sample Database: Pre-loaded Chinook music store database for testing
• Custom Database Upload: Support for SQLite file uploads
• Entity-Relationship Diagrams (ERD): Professional Power BI-style database visualizations
o Full-screen viewing mode
• Custom Database Generator: Describe any business domain and AI creates appropriate schema
• Realistic Dummy Data: Auto-generation of sample data with proper relationships
• Instant Visualization: Immediate ERD generation for created databases
• SQL Q&A Assistant: Ask any SQL/RDBMS question and get detailed explanations
• Curated Tutorials: Links to W3Schools, GeeksforGeeks, SQLBolt, Mode Analytics
• Interview Preparation: Resources from DataCamp, LeetCode, HackerRank
• Practice Challenges: Coding platforms and skill assessments
• Structured Learning Paths: Beginner to advanced progression
streamlit
langchain-community
langchain-openai
langchain-groq
sqlite3
pymysql
requests
faker
Optional Dependencies (for advanced features)
graphviz # For ERD generation
sqlalchemy # For database introspection
git clone
cd sql-agent-app
pip install streamlit langchain-community langchain-openai langchain-groq
pip install plotly pandas pymysql faker requests
pip install graphviz sqlalchemy # Optional for ERD features
streamlit run app10.py
- Choose API provider (OpenAI or Groq)
- Enter your API key:
o OpenAI: Get from platform.openai.com/api-keys
o Groq: Get from console.groq.com/keys
4. Select your database option
5. Start querying!
- Sample Chinook Database
• Pre-loaded music store database
• Ideal for learning and testing
• Contains customers, tracks, albums, artists, invoices - Upload Custom SQLite Database
• Upload your own .db files
• Automatic validation and schema analysis
• Instant querying capabilities - Connect to MySQL Database
• Remote MySQL server connection
• Full credential management
• Connection testing and validation - Create Custom Database
• Describe any business domain
• AI generates appropriate schema
• Auto-populated with realistic data
• Example domains: e-commerce, hospital, school, restaurant
• Interactive tutorials and resources
• Interview preparation materials
• Practice challenges and assessments
Natural Language Queries
- "How many customers are from each country?"
- "Show me the top 10 best-selling tracks"
- "What are the total sales by year?"
- "Which genres are most popular?" Database Creation Examples
- "Create a database for an online store with customers, products, and orders"
- "Create a hospital management system with patients and doctors"
- "Create a library system with books, authors, and borrowings"
- Database Manager: Handles connections to SQLite/MySQL databases
- AI Agent: LangChain-powered SQL agent for natural language processing
- Visualization Engine: Automatic chart generation and ERD creation
- Learning Hub: Comprehensive SQL education resources
- User inputs natural language question
- LangChain agent generates appropriate SQL query
- Query executed against database
- Results processed and visualized
- Natural language explanation provided
sql-agent-app/
├── app.py # Main Streamlit application
├── requirements.txt # Python dependencies
├── README.md # This file
└── temp/ # Temporary files (auto-created)
OpenAI Models
• GPT-3.5 Turbo
• GPT-4
• GPT-4 Turbo
• GPT-4o
• GPT-4o Mini
Groq Models
• Llama 3.1 8B Instant
• Llama 3.3 70B Versatile
• Qwen 3 32B
• Gemma2 9B IT
• API keys handled securely through Streamlit secrets
• No persistent storage of sensitive data
• Temporary database files auto-cleanup
• Connection validation and error handling
• Connection pooling and caching
• Optimized query execution
• Progressive loading for large datasets
• Memory-efficient chart generation
• Perfect for SQL learning and practice
• Database design understanding
• Data visualization principles
• Interview preparation
• Real-world data analysis scenarios
- API Key Validation Failed: Verify your API key is correct and has sufficient credits
- Database Connection Error: Check file permissions and database format
- ERD Generation Failed: Install graphviz and sqlalchemy packages
- MySQL Connection Issues: Verify host, port, credentials, and network access
• Comprehensive error messages with suggestions
• Graceful fallbacks for missing dependencies
• Connection retry mechanisms \
• User-friendly error displays
MIT License - See LICENSE file for details