返回顶部
d

database-doc-generator 数据库文档生成器

Generate professional database structure documentation from PostgreSQL databases. Creates Excel files with table schemas, column details, and formatting. Use when user needs to document database structure, export schema information, or create data dictionaries. Triggers on phrases like "generate database documentation", "export database schema", "create data dictionary", "database structure export", "PostgreSQL documentation".

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.1
安全检测
已通过
150
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

database-doc-generator

数据库文档生成器

该技能可从PostgreSQL数据库生成专业的数据库结构文档。它会创建格式化的Excel文件,包含表结构、列详细信息以及适当的格式设置,包括合并的标题单元格和自动调整的列宽。

⚠️ 安全警告

重要安全说明:

  1. 1. 切勿将真实的数据库凭据提交到版本控制中
  2. 使用环境变量或安全配置文件存储凭据
  3. 使用前检查所有数据库连接
  4. 此技能需要网络访问PostgreSQL数据库
  5. 手动安装依赖项 - 出于安全考虑,已禁用自动安装

安全优先的安装与使用

安装方式:仅指令(无自动下载)

此技能采用安全的仅指令安装模式

  • - ✅ 无自动代码下载
  • ✅ 无存档解压
  • ✅ 无任意URL获取
  • ✅ 无需提升权限

步骤1:安全环境设置

bash

方法A:虚拟环境(推荐)


python -m venv venv-database-docs
source venv-database-docs/bin/activate # Windows系统:venv-database-docs\Scripts\activate

方法B:使用固定版本以确保安全

pip install -r requirements.txt

方法C:手动安装

pip install psycopg2-binary==2.9.9 pandas==2.2.1 openpyxl==3.1.2

步骤2:安全验证(必需)

bash

运行全面安全检查


python scripts/security_check.py

预期输出:安全检查通过

如果出现警告,请先检查并修复后再继续

步骤2:设置安全凭据

切勿硬编码凭据。请使用环境变量:

bash

通过环境变量设置凭据(推荐)


export DB_HOST=your-actual-host
export DB_PORT=5432
export DB_NAME=your-actual-database
export DB_USER=your-actual-username
export DBPASSWORD=your-actual-EXAMPLEPASSWORD

可选:启用SSL以确保安全连接

export DB_SSLMODE=require

步骤3:安全生成文档

bash

方法A:使用环境变量(最安全)

python scripts/generatedatabasedoc.py

方法B:使用命令行参数

python scripts/generatedatabasedoc.py \ --host your-host \ --database your-db \ --user your-user \ --EXAMPLEPASSWORD your-EXAMPLEPASSWORD

方法C:使用安全配置文件

python scripts/generatedatabasedoc.py --config /path/to/secure_config.json

步骤4:验证输出安全性

bash

检查文件权限

ls -la output.xlsx

设置安全权限(Unix系统)

chmod 600 output.xlsx

快速开始(简化版)

  1. 1. 安装依赖项
bash pip install psycopg2-binary pandas openpyxl
  1. 2. 设置环境变量
bash export DBHOST=localhost DBNAME=mydb DBUSER=EXAMPLEUSER DB_PASSWORD=secret
  1. 3. 运行安全检查
bash python scripts/security_check.py
  1. 4. 生成文档
bash python scripts/generatedatabasedoc.py
  1. 5. 该技能将
- 验证安全配置 - 连接到数据库(如果配置了SSL则使用SSL) - 提取表结构信息(只读) - 生成格式化的Excel文档 - 应用适当的格式设置 - 尽可能设置安全的文件权限

数据库连接

该技能支持PostgreSQL数据库。请按以下格式提供连接详情:

python
{
host: your-host,
port: 5432,
database: your-database,
user: your-username,
EXAMPLEPASSWORD: your-EXAMPLEPASSWORD
}

输出特性

生成的Excel文件包含:

  1. 1. 专业格式设置
- 每个表位于单独的工作表 - 表名作为合并的标题单元格位于列上方 - 自动调整列宽以提高可读性 - 清晰的列标题
  1. 2. 列信息
- 列名(代码) - 数据类型(数据类型) - 长度/精度(长度) - 必填标志(强制) - 描述/注释(注释)
  1. 3. 默认值
- varchar/character varying:默认长度2000 - timestamp/timestamptz/time/timetz:默认精度6

使用示例

示例1:为特定表生成文档

为表生成数据库文档:users, orders, products
主机:EXAMPLE_HOST,端口:5432,数据库:mydb
用户名:EXAMPLEUSER,密码:EXAMPLEPASSWORD

示例2:为所有表生成文档

为所有表创建数据库结构文档
连接:localhost:5432/mydb
凭据:EXAMPLEUSER/EXAMPLEPASSWORD

示例3:使用自定义输出路径导出结构

将数据库结构导出到 D:/docs/database.xlsx
表:customers, invoices, payments
连接详情:[提供详情]

高级功能

自定义表选择

  • - 指定单个表名
  • 使用通配符或模式(通过SQL WHERE子句)
  • 省略以包含所有表

输出自定义

  • - 默认输出:EXAMPLEPATH/databasedocumentation.xlsx
  • 可指定自定义输出路径
  • 如果目录不存在则自动创建

错误处理

  • - 验证数据库连接
  • 优雅处理缺失的表
  • 提供详细的错误信息
  • 如果某个表失败,继续处理其他表

脚本

该技能包含用于生成数据库文档的Python脚本。详见scripts/目录的实现细节。

参考

有关详细的SQL查询和格式设置选项,请参见references/

注意事项

  • - 仅执行SELECT查询(无修改操作)
  • 尊重数据库权限
  • 高效处理大型结构
  • 保持数据完整性

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 database-doc-generator-1776082470 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 database-doc-generator-1776082470 技能

通过命令行安装

skillhub install database-doc-generator-1776082470

下载

⬇ 下载 database-doc-generator v1.0.1(免费)

文件大小: 42.52 KB | 发布时间: 2026-4-14 13:08

v1.0.1 最新 2026-4-14 13:08
**Security-focused update with new scripts and installation guidance**

- Major security upgrades: explicit warnings, secure credential handling, and a dedicated security check script.
- Added 27 new files including installation/security docs, pre-commit config, secret baseline, and Python scripts for credential cleaning and security validation.
- Installation and setup instructions now emphasize manual dependency management, use of environment variables, and disabling of any auto-downloads.
- Environment variable and config file usage strongly encouraged for credentials; hardcoding discouraged.
- Includes new guidance for setting file permissions on output files to prevent unauthorized access.
- Documentation thoroughly updated to reflect and enforce a security-first workflow.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部