File size: 3,195 Bytes
f63fd08
 
 
 
 
 
 
f29fe89
f63fd08
 
 
9998bc3
 
7f347eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
title: AI Database Query Assistant
emoji: πŸ€–
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: "4.0.0"
app_file: server.py
pinned: false
---

# Warning: This project may not work due to Hugging Face restrictions. Please check out the GitHub repo for the latest updates.

<iframe width="560" height="315" src="https://www.youtube.com/embed/0kAYAxU7YsQ?si=6ENuemAOXeLNyh-I" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>



# πŸ€– AI Database Query Assistant

A powerful AI-powered database query assistant that allows you to interact with your MySQL database using natural language.

## 🏷️ Tags
- agent-demo-track

## ✨ Features

### Database Connection
- Secure MySQL database connection with support for:
  - Custom host and port configuration
  - Username and password authentication
  - Special character support in passwords
  - Default port (3306) handling
  - Connection status monitoring

### AI-Powered Query Processing
- Natural language to SQL conversion using Google's Gemini model
- Intelligent query validation and error handling
- Automatic query correction and optimization
- Support for complex SQL operations including:
  - Joins
  - Aggregations
  - Subqueries
  - Complex functions

### Database Analysis
- Comprehensive database structure analysis
- Table schema visualization
- Column information display
- Primary and foreign key relationship mapping
- Row count statistics

### Query Features
- Natural language question processing
- SQL query generation and execution
- Query performance metrics:
  - Execution time tracking
  - Row count statistics
  - Query complexity analysis
  - Performance insights

### Query History
- Track and store query history
- View past queries with:
  - Timestamp
  - Original question
  - Generated SQL
  - Execution metrics
  - Complexity level
- Reuse previous queries
- Clear history functionality

### Security Features
- Secure password handling
- SQL injection prevention
- Query validation
- API key management:
  - Environment variable support
  - User-provided key option
  - Secure key storage

### User Interface
- Modern Gradio-based interface
- Tabbed navigation
- Real-time status updates
- Interactive query input
- Formatted result display
- Example questions for guidance

### Performance Monitoring
- Query execution time tracking
- Complexity analysis
- Performance insights
- Resource usage optimization

### Error Handling
- Comprehensive error detection
- User-friendly error messages
- Automatic query correction
- Detailed error reporting

## πŸš€ Getting Started

1. Install the required dependencies
2. Set up your Google API key (for Gemini model)
3. Configure your MySQL database connection
4. Launch the application
5. Start querying your database using natural language!

## πŸ”§ Requirements

- Python 3.x
- MySQL database
- Google API key for Gemini model
- Required Python packages (see requirements.txt)

## πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.