/install db-query
Database Query
Overview
Query databases through a centralized configuration file with automatic SSH tunnel management. Handles connection details, SSH tunnel setup/teardown, and query execution.
Security
Passwords are never exposed in process lists. The skill uses environment variables for credentials:
MYSQL_PWDfor database passwords (passed to mysql client)SSHPASSfor SSH tunnel passwords (passed to sshpass)
Recommended: Store credentials in environment variables instead of the config file for better security.
Configuration
Setup
-
Create config file at
~/.config/clawdbot/db-config.json:mkdir -p ~/.config/clawdbot # Copy example config and edit cp /usr/lib/node_modules/clawdbot/skills/db-query/scripts/config.example.json ~/.config/clawdbot/db-config.json -
Add database entries with these fields:
name: Description used to find the database (required)host: Database host (required)port: Database port (default: 3306)database: Database name (required)user: Database user (required)password: Database password (optional, can use env var)ssh_tunnel: Optional SSH tunnel configuration
-
SSH tunnel configuration (if needed):
enabled: true/falsessh_host: Remote SSH hostssh_user: SSH usernamessh_port: SSH port (default: 22)local_port: Local port to forward (e.g., 3307)remote_host: Remote database host behind SSH (default: localhost)remote_port: Remote database port (default: 3306)
Environment Variables (Recommended)
Instead of storing passwords in the config file, use environment variables:
# Format: DB_PASSWORD_\x3CDATABASE_NAME> (spaces replaced with underscores, uppercase)
export DB_PASSWORD_PRODUCTION_USER_DB="your_db_password"
# Format: SSH_PASSWORD_\x3CDATABASE_NAME> for SSH tunnel password
export SSH_PASSWORD_PRODUCTION_USER_DB="your_ssh_password"
Example Config
{
"databases": [
{
"name": "Production User DB",
"host": "localhost",
"port": 3306,
"database": "user_db",
"user": "db_user",
"password": "",
"ssh_tunnel": {
"enabled": true,
"ssh_host": "prod.example.com",
"ssh_user": "deploy",
"local_port": 3307
}
}
]
}
Set environment variables (recommended):
export DB_PASSWORD_PRODUCTION_USER_DB="your_db_password"
export SSH_PASSWORD_PRODUCTION_USER_DB="your_ssh_password"
Usage
List Databases
python3 /usr/lib/node_modules/clawdbot/skills/db-query/scripts/db_query.py --list
Query a Database
python3 /usr/lib/node_modules/clawdbot/skills/db-query/scripts/db_query.py \
--database "Production User DB" \
--query "SELECT * FROM users LIMIT 10"
The script will:
- Find database by matching description in config
- Start SSH tunnel (if configured)
- Execute query
- Automatically close SSH tunnel (important for cleanup)
With Custom Config Path
python3 /usr/lib/node_modules/clawdbot/skills/db-query/scripts/db_query.py \
--config /path/to/custom-config.json \
--database "test" \
--query "SHOW TABLES"
Requirements
- MySQL client:
apt install mysql-clientor equivalent - SSH client: usually pre-installed on Linux/Mac
- Python 3.6+
Notes
- SSH tunnels are automatically closed after query execution
- Use
--listto see all configured databases and their descriptions - Database search is case-insensitive partial match on
namefield - Local ports for SSH tunnels should be unique per database
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install db-query - 安装完成后,直接呼叫该 Skill 的名称或使用
/db-query触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
MYSQL QUERY 是什么?
Query project databases with automatic SSH tunnel management. Use when you need to execute SQL queries against configured databases, especially those accessi... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 3270 次。
如何安装 MYSQL QUERY?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install db-query」即可一键安装,无需额外配置。
MYSQL QUERY 是免费的吗?
是的,MYSQL QUERY 完全免费(开源免费),可自由下载、安装和使用。
MYSQL QUERY 支持哪些平台?
MYSQL QUERY 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 MYSQL QUERY?
由 zenixp(@zenixp)开发并维护,当前版本 v1.0.1。