Database Tools
MyDeskBot Desktop provides powerful database tools that allow you to interact with databases directly from your AI assistant.
Features
Connect to Databases
MyDeskBot supports multiple database connections:
- PostgreSQL
- MySQL
- SQLite
- Microsoft SQL Server
Database Operations
The AI assistant can perform the following database operations:
- Query data with natural language
- Insert, update, and delete records
- Create and modify tables
- Run custom SQL queries
- Export query results
- Visualize data
Integration with AI
The database tools are deeply integrated with the AI assistant:
User: "Show me all users who registered in the last week"
AI: [Automatically generates SQL query]
SELECT * FROM users WHERE created_at >= NOW() - INTERVAL '7 days';Setup
1. Configure Database Connections
- Open MyDeskBot Desktop
- Go to Settings → Database
- Click "Add Connection"
- Fill in the connection details:
- Database type
- Host address
- Port number
- Database name
- Username and password
2. Test Connection
After configuring, click "Test Connection" to verify the database is accessible.
Usage Examples
Natural Language Queries
markdown
User: "How many orders were placed this month?"
AI: [Queries the database]
"1,247 orders were placed this month."Data Analysis
markdown
User: "Analyze sales trends over the past year"
AI: [Runs multiple queries and creates visualization]
"Here's a breakdown of your sales trends..."Data Export
markdown
User: "Export all users who subscribed to the premium plan"
AI: [Queries and exports data]
"Exported 842 records to CSV file."Security
Connection Security
- All database connections use SSL/TLS encryption
- Credentials are stored securely in your keychain
- Connections can be configured to require re-authentication
AI Safety
- The AI cannot execute destructive operations without confirmation
- Write operations (INSERT, UPDATE, DELETE) require explicit approval
- Destructive operations (DROP, TRUNCATE) require double confirmation
Best Practices
1. Use Descriptive Table Names
sql
-- Good
CREATE TABLE customer_orders (
id SERIAL PRIMARY KEY,
customer_id INTEGER,
order_date TIMESTAMP
);
-- Avoid
CREATE TABLE t1 (
id INT,
c_id INT,
date DATETIME
);2. Add Indexes for Performance
sql
CREATE INDEX idx_orders_date ON customer_orders(order_date);3. Use Prepared Statements
The AI assistant automatically uses prepared statements to prevent SQL injection.
4. Limit Query Results
markdown
User: "Show me the first 100 users"
AI: [Executes SELECT * FROM users LIMIT 100]Troubleshooting
Connection Failed
- Verify database credentials
- Check if the database is running
- Ensure firewall allows the connection
- Check SSL/TLS settings
Slow Queries
- Add appropriate indexes
- Optimize WHERE clauses
- Consider query caching
- Use EXPLAIN to analyze query plans
Permission Denied
- Verify user has necessary permissions
- Check database role assignments
- Ensure user has access to the specific database/schema
Advanced Features
Query Templates
Save frequently used queries as templates:
sql
-- Template: Get active users
SELECT COUNT(*) FROM users WHERE last_active > NOW() - INTERVAL '7 days';Query History
All queries executed through the AI are logged and can be reviewed in Settings → Database → History.
Custom AI Rules
Create rules for how the AI interacts with your database:
json
{
"databaseRules": {
"allowDestructive": false,
"requireConfirmationForWrites": true,
"maxResultLimit": 10000,
"allowedTables": ["users", "orders", "products"]
}
}