Browser & AutomationDocumentedScanned
db-query
Query project databases with automatic SSH tunnel management.
Share:
Installation
npx clawhub@latest install db-queryView the full skill documentation and source below.
Documentation
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.
Configuration
Setup
~/.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
-
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 (required)-
ssh_tunnel: Optional SSH tunnel configuration
-
enabled: true/false-
ssh_host: Remote SSH host-
ssh_user: SSH username-
ssh_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)
Example Config
{
"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
}
}
]
}
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 "生产用户库" \
--query "SELECT * FROM users LIMIT 10"
The script will:
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