Query project databases with automatic SSH tunnel management. Use when you need to execute SQL queries against configured databases, especially those accessible only via SSH tunnels. Automatically manages SSH connection lifecycle (establishes tunnel before query, closes after). Supports multiple databases distinguished by description/name from config file.
Query databases through a centralized configuration file with automatic SSH tunnel management. Handles connection details, SSH tunnel setup/teardown, and query execution.
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)portdatabase: Database name (required)user: Database user (required)password: Database password (required)ssh_tunnel: Optional SSH tunnel configurationSSH 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){
"databases": [
{
"name": "生产用户库",
"host": "localhost",
"port": 3306,
"database": "user_db",
"user": "db_user",
"password": "secret",
"ssh_tunnel": {
"enabled": true,
"ssh_host": "prod.example.com",
"ssh_user": "deploy",
"local_port": 3307
}
}
]
}
python3 /usr/lib/node_modules/clawdbot/skills/db-query/scripts/db_query.py --list
python3 /usr/lib/node_modules/clawdbot/skills/db-query/scripts/db_query.py \
--database "生产用户库" \
--query "SELECT * FROM users LIMIT 10"
The script will:
python3 /usr/lib/node_modules/clawdbot/skills/db-query/scripts/db_query.py \
--config /path/to/custom-config.json \
--database "test" \
--query "SHOW TABLES"
apt install mysql-client or equivalent--list to see all configured databases and their descriptionsname field