by zhouyanye
SQL → classic Chen ER diagrams & Word design docs. CLI + Agent Skill. Online: yanleaf.com/tools/sql-to-er
# Add to your Claude Code skills
git clone https://github.com/zhouyanye/sql-to-ersql-to-er is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by zhouyanye. SQL → classic Chen ER diagrams & Word design docs. CLI + Agent Skill. Online: yanleaf.com/tools/sql-to-er. It has 0 GitHub stars.
sql-to-er's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/zhouyanye/sql-to-er" and add it to your Claude Code skills directory (see the Installation section above). sql-to-er ships a SKILL.md manifest, so compatible agents can discover and load it automatically.
sql-to-er is primarily written in Python. It is open-source under zhouyanye on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh sql-to-er against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM is an informational directory and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
经典 Chen 风格 ER 图 +(按需)Word 三线表 / Mermaid / GoJS。
在以下情况使用:
.sql / 粘贴 CREATE TABLE,并要求出图或设计文档不要在仅讨论 SQL 语法、改某一个字段时自动出图。
只生成用户要的东西。 未点名的格式不要跑、不要塞给用户。
| 用户说法 | 生成 |
|---|---|
| 画 ER 图 / 生成 ERD / 看看图 | 仅 PNG(--format png) |
| 要 Mermaid / 要代码块图 | 仅 Mermaid(--format mermaid) |
| 数据库设计文档 / 三线表 / Word / docx | 仅 Word(--format word) |
| GoJS / 给前端用的 JSON | 仅 GoJS(--format gojs) |
| 全部 / 图和文档都要 / 导出全套 | --format all |
默认(只说「画个 ER 图」):PNG only。
不要默认执行 --format all。
# 只要图(最常见)
python scripts/sql_to_erd.py schema.sql --out /tmp/erd --format png
# 只要 Word
python scripts/sql_to_erd.py schema.sql --out /tmp/design --format word
# 用户明确要全套
python scripts/sql_to_erd.py schema.sql --out /tmp/erd --format all
解析:优先 https://yanleaf.com/api/tools/er-diagram/parse,失败本地 sql_parser.py。
引擎:--engine auto(有 dot 用 Graphviz,否则 matplotlib)。一般无需改。
xxx_id、审计字段、3NF)。python scripts/render_chen.py /tmp/tables.json /tmp/erd.png yanleaf.com
只要 Word 则用 export_word.py,不要顺手再出 PNG/Mermaid。
--max-attrs)pip install sqlparse pyyaml python-docx pillow matplotlib graphviz
Graphviz 系统包可选;没有也能出 PNG。中文需系统字体或 assets/ 内字体。
| 文件 | 作用 |
|---|---|
sql_to_erd.py |
SQL 入口(用 --format 控制产物) |
render_chen.py |
matplotlib Chen PNG |
api_client.py |
yanleaf parse API |
sql_parser.py |
本地解析回退 |
generate_erd.py |
Mermaid / GoJS / Graphviz DOT |
export_word.py |
Word 三线表 |
watermark.py |
Graphviz PNG 水印 |
SQL → 经典 Chen 风格 ER 图 & Word 三线表设计文档。
作者:zhouyanye · 在线版:https://yanleaf.com/tools/sql-to-er
CREATE TABLESKILL.md)pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
pip install sqlparse pyyaml python-docx pillow matplotlib graphviz
有系统 Graphviz(dot)时 PNG 更接近官网布局;没有则自动用 matplotlib 黑白图。SVG/DOT 仍需要 Graphviz。
| 系统 | 安装 |
|---|---|
| Windows | Graphviz 安装包 或 winget install Graphviz.Graphviz(Chocolatey 需管理员时可用安装包/便携版) |
| macOS | brew install graphviz |
| Ubuntu/Debian | sudo apt install graphviz |
| Fedora | sudo dnf install graphviz |
装不上可忽略,PNG 仍可用。
matplotlib 会按顺序尝试:assets/ 内字体 → Noto CJK → 微软雅黑 → 黑体 → 文泉驿 → PingFang。
若中文仍为方框,任选其一:
sudo apt install fonts-noto-cjk 或把 .ttf/.otf 放进 assets/# 推荐:图 + Word + Mermaid
python scripts/sql_to_erd.py your.sql --out erd --format all
# 只要 PNG
python scripts/sql_to_erd.py your.sql --format png --out erd
# 只要 Word
python scripts/sql_to_erd.py your.sql --format word --out design
# 强制本地解析、关闭水印
python scripts/sql_to_erd.py your.sql --no-api --no-watermark --format png
复制本目录到 Agent skills 路径(如 .grok/skills/er-diagram/)。
er-diagram/
├── SKILL.md
├── README.md
├── LICENSE
├── scripts/
│ ├── sql_to_erd.py
│ ├── render_chen.py # matplotlib Chen 渲染
│ ├── api_client.py
│ ├── sql_parser.py
│ ├── generate_erd.py
│ ├── export_word.py
│ └── watermark.py
└── assets/
├── DejaVuSans.ttf
└── example-model.yaml

MIT © zhouyanye
DejaVu 字体遵循其原许可。