Interact with your SQL Server database using natural language
Features • Installation • Usage • Contributing • Roadmap
This project bridges the gap between natural language and SQL queries by leveraging AI models from Ollama. Ask questions about your database in plain English (or Arabic), and get instant SQL queries and results - no SQL expertise required!
- Natural Language to SQL - Ask questions in plain English and get SQL queries
- Web Interface - Beautiful Streamlit UI for easy interaction
- Analytics Dashboard - Track query patterns and database usage
- Multi-Model Support - Choose from various Ollama models (llama3, codellama, mistral)
- Comprehensive Schema Analysis - Detailed extraction of tables, relationships, and indexes
- Query History - Save and analyze past queries
- Multilingual Support - Documentation in English and Arabic
- Python 3.10+
- Microsoft SQL Server
- Ollama running locally or remotely
- Required Python packages (see Installation)
# Clone the repository
git clone https://github.com/mohammednabarawy/SQL_Query_Generator.git
cd mssql-ai-analyzer
# Install dependencies
pip install -r requirements.txt
# Configure your database connection in config.py
# Start the web interface
streamlit run app.py
- Ensure you have Python 3.10+ installed
- Install the ODBC Driver for SQL Server
- Install Ollama and start the service
- Install the required Python packages:
pip install pyodbc requests streamlit pandas plotly matplotlib
- Configure your database connection in
config.py
python ollama_mssql.py
streamlit run app.py
streamlit run dashboard.py
- "Show me the top 10 customers by total purchase amount"
- "Find all invoices that are overdue by more than 30 days"
- "What's the average order value by month for the last year?"
- "List all employees hired in 2024 with their department"
Edit config.py
to customize:
- Database connection settings
- Ollama API endpoint
- Default and recommended models
- Sample data limits
We welcome contributions from the community! Here's how you can help:
- Fork the repository - Create your own copy of the project
- Create a feature branch -
git checkout -b feature/amazing-feature
- Commit your changes -
git commit -m 'Add some amazing feature'
- Push to your branch -
git push origin feature/amazing-feature
- Open a Pull Request - We'll review and merge your contribution
- Add support for more database systems (PostgreSQL, MySQL, etc.)
- Implement query optimization suggestions
- Create visualization tools for query results
- Add support for more languages
- Improve the AI prompts for better SQL generation
- Write comprehensive tests
- Support for more database systems
- Advanced query optimization
- User authentication and role-based access
- Export capabilities to various formats
- Integration with BI tools
- Scheduled queries and alerts
The application uses Ollama's AI models locally, ensuring:
- Privacy - Your data never leaves your system
- Speed - No network latency for AI processing
- Customization - Fine-tune models for your specific database
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the developers of PyODBC, Requests, Streamlit, Pandas, Plotly, and Ollama
- Special thanks to all contributors who help improve this project
يُقدم هذا المشروع حلاً شاملاً لتحليل واستعلام قواعد بيانات Microsoft SQL Server باستخدام نماذج الذكاء الاصطناعي من Ollama. يجمع هذا التطبيق بين توليد الاستعلامات باستخدام الذكاء الاصطناعي وتنفيذ SQL المباشر، مما يجعل عملية الاستعلام أكثر كفاءة وسهولة من خلال واجهة سطر الأوامر وواجهة الويب.
الهدف الرئيسي من هذا المشروع هو تبسيط عملية استعلام قواعد البيانات عبر SQL Server باستخدام قوة نماذج Ollama AI. يمكن للمستخدمين إدخال استعلامات باللغة الطبيعية، وسيقوم التطبيق بتوليد الاستعلامات SQL المقابلة وتنفيذها على قاعدة البيانات.
- تحويل اللغة الطبيعية إلى SQL - اطرح أسئلة باللغة العربية أو الإنجليزية واحصل على استعلامات SQL
- واجهة ويب - واجهة مستخدم جميلة باستخدام Streamlit للتفاعل السهل
- لوحة تحليلات - تتبع أنماط الاستعلام واستخدام قاعدة البيانات
- دعم نماذج متعددة - اختر من بين نماذج Ollama المختلفة (llama3, codellama, mistral)
- تحليل شامل للمخطط - استخراج مفصل للجداول والعلاقات والفهارس
- سجل الاستعلامات - حفظ وتحليل الاستعلامات السابقة
- دعم متعدد اللغات - وثائق باللغتين العربية والإنجليزية
Made with ❤️ by developers, for developers
Star ⭐ this repository if you find it useful!