adb-mysql

阿里云 AnalyticDB (ADB) for MySQL 只读数据分析。 多维分析(计数/聚合/时间序列)、交叉验证、Schema 文档生成、多 Profile。

5 stars

Best use case

adb-mysql is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

阿里云 AnalyticDB (ADB) for MySQL 只读数据分析。 多维分析(计数/聚合/时间序列)、交叉验证、Schema 文档生成、多 Profile。

Teams using adb-mysql should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/adb-mysql/SKILL.md --create-dirs "https://raw.githubusercontent.com/northseadl/norix-skills/main/adb-mysql/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/adb-mysql/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How adb-mysql Compares

Feature / Agentadb-mysqlStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

阿里云 AnalyticDB (ADB) for MySQL 只读数据分析。 多维分析(计数/聚合/时间序列)、交叉验证、Schema 文档生成、多 Profile。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# ADB 数据分析技能

## 安装

```bash
pip install pymysql
```

仅依赖 `pymysql`(纯 Python MySQL 驱动),无需本地 `mysql` 客户端。

## 配置

### 添加连接

```bash
./adb config add <profile-name> \
  --host <DMS代理地址或ADB实例地址> \
  --user <AccessID或用户名> \
  --password <AccessSecret或密码> \
  --database <数据库名> \
  --test
```

凭据存储在 `~/.adb-mysql/profiles.json`(权限 `0600`),支持多 Profile。

### 管理连接

```bash
./adb config list                    # 列出所有 profile
./adb config use <profile-name>      # 切换默认 profile
./adb config test [profile-name]     # 测试连接
./adb config remove <profile-name>   # 删除 profile
```

## 脚本

### query — SQL 查询(只读)

```bash
./adb query "SELECT * FROM users LIMIT 10"
./adb query -d mydb "SELECT COUNT(*) FROM orders"
./adb query -f report.sql --format csv
./adb query -p staging "SELECT 1"          # 指定 profile
```

选项:`-p` profile / `-d` 数据库 / `-f` SQL 文件 / `--format table|csv|json`

### analyze — 数据分析(带交叉验证)

```bash
./adb analyze -t orders -c                                    # 计数分析
./adb analyze -t orders -g status -a "SUM(amount)"            # 聚合分析
./adb analyze -t orders --time-col created_at \
  --start-date 2024-01-01 --end-date 2024-02-01               # 时间序列
```

每次分析自动执行交叉验证:总行数 → 随机样本 → 数值统计 → 时间范围。

### schema — Schema 文档生成

```bash
./adb schema mydb                    # 生成到 ~/.adb-mysql/schema/mydb/
./adb schema mydb -o ./docs/schema   # 自定义输出目录
```

为所有表生成 Markdown 文档(字段定义、索引、ADB 分布键、查询示例)+ 索引文件。

**Agent 工作流**: 首次分析某数据库前,先运行 `./adb schema` 生成文档到 `~/.adb-mysql/schema/`,后续分析时读取作为上下文。

## 安全策略

- **只读**: 正则拦截 INSERT / UPDATE / DELETE / DROP / CREATE / ALTER / TRUNCATE 等写入操作
- **行数限制**: 自动添加 `LIMIT 200`,超出自动截断
- **性能警告**: 检测 SELECT * / 缺少 WHERE / JOIN 无 ON 条件
- **凭据安全**: 配置文件权限 `0600`,密码不出现在命令行参数

## 模块架构

```
adb (Bash CLI 入口)
│
├── config   → config.py    多 Profile 连接管理 (add/list/use/test/remove)
├── query    → query.py     SQL 只读查询 (table/csv/json 输出)
├── analyze  → analyze.py   多维分析 + 交叉验证
└── schema   → schema.py    Schema 文档生成 (Markdown)
               ↓
            adb_core.py      核心引擎 (pymysql 连接 + SQL 安全 + 输出格式化)
               ↓
         ~/.adb-mysql/
           ├── profiles.json  连接配置
           └── schema/        Schema 文档输出
```

Related Skills

web-scraper

5
from northseadl/norix-skills

Web scraper with SPA/JavaScript rendering, page interaction, and JS execution. Two-tier engine (HTTP → Playwright browser). Smart discovery, batch fetch, interactive content extraction, OpenAPI parsing. Use when read_url_content fails, SPA rendering needed, or page interaction required.

pm-toolkit

5
from northseadl/norix-skills

自然语言 → Mermaid 图表(16 种)+ 网页原型,本地 Web 面板实时预览/导出。

mobile-testing

5
from northseadl/norix-skills

Android/iOS automated testing: device management, app install, performance profiling, log analysis, screenshot comparison, Maestro E2E orchestration.

llm-agent-dev

5
from northseadl/norix-skills

LLM Agent engineering: pattern selection (12-mode matrix), data simulation, convergence iteration. Covers intent routing, function calling, ReAct, MCP, prompt chaining, guardrails, evaluation.

image-studio

5
from northseadl/norix-skills

AI image generation and editing: e-commerce templates (hero/banner/detail/lifestyle), image refinement (background replace/remove, enhance, retouch, style transfer), icon extraction (bg-removal + detect + smart crop with transparent output).

feishu-integration

5
from northseadl/norix-skills

Feishu (Lark) unified CLI for tasks, documents, wiki, bitable, messaging, approval, and Drive. Supports search/create/edit/publish/export across all modules. Use when reading/writing Feishu docs, searching docs or wiki, managing tasks, sending messages, creating approvals, exporting to Markdown, or any 飞书/Lark interaction.

es-analytics

5
from northseadl/norix-skills

Elasticsearch / SLS 只读数据分析:索引探索、mapping、聚合统计、日志搜索、时间序列、多 Profile。

doc-sentinel

5
from northseadl/norix-skills

Document-code change notification system: traceable doc-code binding via git tree hash, git-diff-driven reconciliation plans with confidence/risk metadata, and idempotent execution. Use when maintaining documentation freshness, detecting stale docs, or binding docs to source code.

coding-net-integration

5
from northseadl/norix-skills

Coding.net DevOps automation: MR lifecycle, CI operations (trigger/logs/stop), artifact registry, cross-project queries, remote file audit.

cnb-cool-integration

5
from northseadl/norix-skills

针对 cnb.cool 的云原生构建(CNB Build):生成/修改 .cnb.yml 流水线、触发规则、 构建环境、runner 资源、缓存、环境变量、手动触发与调试。 在接入、迁移、优化或排查 CNB 构建配置时使用。

agent-task-orchestration

5
from northseadl/norix-skills

Task decomposition and multi-agent orchestration with retry, checkpoint recovery, and real-time monitoring. Mixed Codex/Claude Code engine. Parallel/sequential execution.

agent-swe-team

5
from northseadl/norix-skills

Multi-agent SWE team built on the Workshop model. Full-stack vertical workers, meeting room with @mention notification, private pipes, shared task board. Git worktree isolation, Leader-driven coordination. Mixed Codex/Claude Code engine. Use when a task needs engineering depth beyond a single agent. NOT for simple task parallelism (use agent-task-orchestration) or design discussions (use agent-brainstorm).