‹ 首页

db-mysql

@evolution-foundation · 收录于 5 天前 · 上游提交 2 个月前

Query MySQL / MariaDB databases configured in .env (DB_MYSQL_N_*). Use when the user asks to query, explore, or audit data in a MySQL database. Picks connection by label (e.g. 'orders-dev', 'analytics-prod') or numeric index. Read-only by default — writes refused unless DB_MYSQL_N_ALLOW_WRITE=true on that block.

适合你,如果你需要快速查询或审计 MySQL 数据库中的数据

/ 通过 npx 安装 校验哈希
npx oh-my-skill add evolution-foundation/evo-nexus/db-mysql
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- evolution-foundation/evo-nexus/db-mysql
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify evolution-foundation/evo-nexus/db-mysql
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
509GitHub stars
~1.5K最小装载
~1.5K含声明引用
~4.1K文本包总量
索引托管

怎么用

商店整理自技能原文 · 版本 7f5dd76 · 表述以原文为准
它做什么

装上后,Claude 可以查询你配置的 MySQL/MariaDB 数据库(只读,除非特别授权)。它能列出连接、检查连通性、运行查询、查看表结构,结果以 JSON 输出。

什么时候触发

当你要求查询、探索或审计 MySQL 数据库中的数据时触发。需要先在 .env 文件中配置好数据库连接。

装好后可以这样说
Claude 会运行查询并返回结果。
Claude 会显示表名列表。
Claude 会执行健康检查并报告状态。
技能原文 SKILL.md作者撰写 · Apache-2.0 · 7f5dd76

db-mysql

Query MySQL / MariaDB databases declared in .env. Connections follow the same numbered pattern as SOCIAL_YOUTUBE_N_* / SOCIAL_INSTAGRAM_N_* — one block per database, labelled for humans, picked by label or index at call time.

Setup — one-time, per database

Add a block to .env (gitignored). Increment the index per connection:

# ── MySQL: orders-dev ────────────────────────────────
DB_MYSQL_1_LABEL=orders-dev
DB_MYSQL_1_HOST=mysql.dev.internal
DB_MYSQL_1_PORT=3306
DB_MYSQL_1_DATABASE=orders
DB_MYSQL_1_USER=agent_readonly
DB_MYSQL_1_PASSWORD=...                # raw; .env is gitignored
# DB_MYSQL_1_SSL_CA_PATH=/path/ca.pem  # optional, enables TLS verification
# DB_MYSQL_1_ALLOW_WRITE=false         # default false
# DB_MYSQL_1_QUERY_TIMEOUT=30          # seconds, default 30
# DB_MYSQL_1_MAX_ROWS=1000             # default 1000

Alternative — full DSN instead of components (DSN wins when both are set):

DB_MYSQL_2_LABEL=analytics-prod
DB_MYSQL_2_DSN=mysql://agent_ro:***@analytics.prod.internal:3306/analytics

LABEL is always required — it's how agents pick the connection.

Usage

All commands output a single JSON line on stdout (safe to pipe). Errors go to stderr as JSON and exit non-zero.

List configured connections
python3 .claude/skills/db-mysql/scripts/db_client.py accounts
Health-check a connection
python3 .claude/skills/db-mysql/scripts/db_client.py test orders-dev
Run a read-only query
python3 .claude/skills/db-mysql/scripts/db_client.py query orders-dev \
  "SELECT count(*) FROM customers WHERE created_at > now() - interval 7 day"
Explore schema
# List all tables (excludes mysql/information_schema/performance_schema/sys)
python3 .claude/skills/db-mysql/scripts/db_client.py tables orders-dev

# Describe a table
python3 .claude/skills/db-mysql/scripts/db_client.py describe orders-dev customers
# Schema-qualified:
python3 .claude/skills/db-mysql/scripts/db_client.py describe orders-dev analytics.events
Output shape

Successful query:

{
  "ok": true,
  "query_id": "uuid-v4",
  "label": "orders-dev",
  "columns": ["id", "email", "created_at"],
  "rows": [[1, "a@b.com", "2026-04-22 12:00:00"]],
  "row_count": 1,
  "truncated": false,
  "full_result_path": null,
  "execution_time_ms": 12
}

When rows exceed MAX_ROWS, truncated is true and full_result_path points to a CSV in ADWs/logs/db-queries/<query_id>.csv — the agent can read that file directly instead of re-running.

Error:

{"ok": false, "error_code": "write_blocked", "error": "Write query blocked — connection 'orders-dev' has ALLOW_WRITE=false. ...", "label": "orders-dev"}

Error codes:

  • no_connections — no DB_MYSQL_N_* blocks in .env
  • not_found — label/index doesn't match any block
  • ambiguous — multiple blocks share the same label (use index instead)
  • config_error — block present but required field missing (typically LABEL)
  • driver_missingpymysql not installed
  • connection_failed — network, auth, TLS, or MAX_EXECUTION_TIME tripped
  • write_blocked — write verb detected without ALLOW_WRITE=true
  • multi_statement — more than one statement in a single call
  • usage — wrong CLI args
Guardrails
  • Write verbs (DELETE | UPDATE | INSERT | REPLACE | TRUNCATE | DROP | ALTER | CREATE | GRANT | REVOKE | RENAME | LOAD | CALL | HANDLER) — refused unless DB_MYSQL_N_ALLOW_WRITE=true.
  • Multi-statement queries — refused in v1. Supports --, #, and /* */ comment styles.
  • Query timeout — sets SESSION MAX_EXECUTION_TIME = <QUERY_TIMEOUT>s on the session (MySQL 5.7.4+; MariaDB honors max_statement_time but the SET statement is ignored gracefully on older versions).
  • Result size — fetchmany(MAX_ROWS + 1) to detect truncation; full result streamed to CSV when truncated so the agent context never holds >1000 rows.
  • utf8mb4 charset enforced on the connection to avoid mojibake on modern collations.
Workflow
  1. If the user doesn't specify a label, run accounts to see what's configured and pick the one that matches their intent. If ambiguous, ask.
  2. Write the smallest SQL that answers the question — prefer aggregates, LIMIT, and EXPLAIN before dumping rows.
  3. Run via query. Inspect the result.
  4. For performance-sensitive queries, load the deep-dive references below.
Dependencies
  • Python 3.10+
  • pymysql — not pre-installed; uv pip install pymysql on first use. Pure-Python driver, no system libs required.
Deep-dive references

These load the PlanetScale database-skills repo verbatim — same content the upstream authors ship for their own tooling.

Upstream: planetscale/database-skills (MIT). Credit to PlanetScale for the reference content.

按 Apache-2.0 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。