Database Integration Tool
MyDeskBot's database integration functionality is implemented through the built-in databaseClient tool, which allows you to connect to various databases and execute SQL queries using natural language for troubleshooting and data analysis.
Note:
databaseClientis a built-in tool of MyDeskBot and needs to be enabled in the tool configuration before use.
Supported Databases
Relational Databases
- PostgreSQL (
postgresql) - Full feature support with advanced SQL capabilities - MySQL (
mysql) - Complete MySQL database support - SQLite (
sqlite) - Lightweight file-based database support - SQL Server (
sqlserver) - Microsoft SQL Server integration - Oracle (
oracle) - Oracle database connectivity
Big Data & Analytics
- ClickHouse (
clickhouse) - High-performance analytical database - Google BigQuery (
bigquery) - Cloud data warehouse - Snowflake (
snowflake) - Cloud data platform
NoSQL Databases
- MongoDB (
mongodb) - Document database support - Redis (
redis) - In-memory data structure store
Session Usage Examples
Direct Database Tool Usage in Chat
Users can directly request database operations in natural language. MyDeskBot automatically generates and executes the corresponding tool calls:
"Please help me check the number of users in our users table and view the 10 most recently registered users."
MyDeskBot will automatically understand your intent and generate a tool call like this (transparent to users):
# Auto-generated by the model, users don't need to worry about this
tools:
- name: "check-users"
tool: "databaseClient"
args:
databaseType: "postgresql"
serverName: "localhost"
database: "myapp"
username: "postgres"
password: "your_password"
queries:
- "SELECT COUNT(*) as total_users FROM users"
- "SELECT id, name, email, created_at FROM users ORDER BY created_at DESC LIMIT 10"Credential Management
When your database requires authentication, you can provide credentials directly in conversation, or use the connectionString parameter to provide a complete connection string:
"Connect to PostgreSQL database at localhost:5432/myapp, username is postgres, password is your_password, and query the count of users table."
Or use a connection string:
"Use connection string postgresql://postgres:your_password@localhost:5432/myapp to query the count of users table."
Recommendation: For frequently used databases, consider saving connection strings in configuration files to avoid repeatedly entering credentials in conversations.
Getting Started
Basic Query
Simply describe your needs in natural language:
"Help me query the number of users in the users table and show me the first 10 users."
MyDeskBot will automatically generate and execute the corresponding SQL queries.
Using Connection String
"Connect to my MySQL database (address in .env) and show me what tables exist."
SQLite Database
"Help me analyze the data in database.db file, see which products in the products table have prices over 100."
Advanced Usage
Complex Analytics
"Help me analyze the user registration trend over the last 30 days, and the top 10 users who spent the most in the last 7 days."
File-Based Queries
"Execute the queries in analytics.sql file and export the results in CSV format."
Dry Run Mode
"I want to test this UPDATE statement, don't actually execute it, just validate the syntax for me."
Use Cases
📈 Business Intelligence
Generate business insights from your data using natural language:
"Show me the sales revenue by category this year, and the top 20 best-selling products."
🔍 Data Quality Analysis
Check data quality and integrity:
"Help me check the data quality of user records, see if there are duplicate emails or users without orders."
📊 Performance Monitoring
Monitor database performance:
"Check the database performance and show me the slowest queries."
🔧 Database Maintenance
Perform database maintenance tasks:
"Run VACUUM and rebuild indexes on the users table, then show me the table statistics."
Best Practices
- Use Connection Pooling: Enable connection reuse for better performance
- Set Row Limits: Prevent large result sets from overwhelming the system
- Use Dry Run: Validate queries before execution in production
- Monitor Performance: Regularly check query performance and optimization
- Secure Credentials: Use connection strings with proper security
- Batch Queries: Group related queries together
- Choose Appropriate Formats: Use CSV/JSON for data export, tables for analysis
Appendix: Tool Parameters Reference
The databaseClient tool supports the following parameters. When you describe your needs in a conversation, MyDeskBot automatically parses and generates the corresponding tool call:
| Parameter | Type | Description |
|---|---|---|
| databaseType | string | Database type (postgresql, mysql, sqlite, oracle, sqlserver, mongodb, redis, clickhouse, bigquery, snowflake) |
| serverName | string | Database server hostname or IP address |
| port | number | Database server port |
| database | string | Database name to connect to |
| username | string | Database username |
| password | string | Database password |
| connectionString | string | Full connection string (alternative to individual connection parameters) |
| queries | string[] | Array of SQL queries to execute |
| queryFile | string | Path to a file containing SQL queries to execute |
| timeout | number | Query timeout in seconds (default: 30) |
| outputFormat | string | Output format for query results (default, csv, json, vertical) |
| maxRows | number | Maximum number of rows to return for SELECT queries (default: 1000) |
| dryRun | boolean | If true, only validates queries without executing them (default: false) |
Usage Example
When you say "Help me query the users table", MyDeskBot automatically generates an internal call like this (this process is transparent to you):
tool: "databaseClient"
args:
databaseType: "postgresql"
serverName: "localhost"
database: "myapp"
username: "postgres"
password: "your_password"
queries:
- "SELECT * FROM users LIMIT 1000"