/install database-doc-generator
\r \r
Database Documentation Generator\r
\r This skill generates professional database structure documentation from PostgreSQL databases. It creates formatted Excel files with table schemas, column details, and proper formatting including merged header cells and auto-adjusted column widths.\r \r
⚠️ SECURITY WARNING\r
\r IMPORTANT SECURITY NOTES:\r \r
- Never commit real database credentials to source control\r
- Use environment variables or secure configuration files for credentials\r
- Review all database connections before use\r
- This skill requires network access to PostgreSQL databases\r
- Install dependencies manually - automatic installation is disabled for security\r \r
Security-First Installation & Usage\r
\r
Installation Method: Instruction-Only (No Auto-Download)\r
\r This skill uses a secure instruction-only installation model:\r
- ✅ No automatic code downloads\r
- ✅ No archive extraction\r
- ✅ No arbitrary URL fetching\r
- ✅ No elevated permissions required\r \r
Step 1: Secure Environment Setup\r
\r
# Method A: Virtual Environment (RECOMMENDED)\r
python -m venv venv-database-docs\r
source venv-database-docs/bin/activate # On Windows: venv-database-docs\Scripts\activate\r
\r
# Method B: With pinned versions for security\r
pip install -r requirements.txt\r
\r
# Method C: Manual installation\r
pip install psycopg2-binary==2.9.9 pandas==2.2.1 openpyxl==3.1.2\r
```\r
\r
### Step 2: Security Validation (MANDATORY)\r
\r
```bash\r
# Run comprehensive security check\r
python scripts/security_check.py\r
\r
# Expected output: "SECURITY CHECK PASSED"\r
# If warnings appear, review and fix before proceeding\r
```\r
\r
### Step 2: Set Secure Credentials\r
**NEVER hardcode credentials. Use environment variables:**\r
\r
```bash\r
# Set credentials via environment variables (RECOMMENDED)\r
export DB_HOST=your-actual-host\r
export DB_PORT=5432\r
export DB_NAME=your-actual-database\r
export DB_USER=your-actual-username\r
export DB_PASSWORD=your-actual-EXAMPLE_PASSWORD\r
\r
# Optional: Enable SSL for secure connections\r
export DB_SSLMODE=require\r
```\r
\r
### Step 3: Generate Documentation Securely\r
```bash\r
# Method A: Using environment variables (most secure)\r
python scripts/generate_database_doc.py\r
\r
# Method B: With command-line arguments\r
python scripts/generate_database_doc.py \\r
--host your-host \\r
--database your-db \\r
--user your-user \\r
--EXAMPLE_PASSWORD your-EXAMPLE_PASSWORD\r
\r
# Method C: Using secure config file\r
python scripts/generate_database_doc.py --config /path/to/secure_config.json\r
```\r
\r
### Step 4: Verify Output Security\r
```bash\r
# Check file permissions\r
ls -la output.xlsx\r
\r
# Set secure permissions (Unix)\r
chmod 600 output.xlsx\r
```\r
\r
## Quick Start (Simplified)\r
\r
1. **Install dependencies**:\r
```bash\r
pip install psycopg2-binary pandas openpyxl\r
```\r
\r
2. **Set environment variables**:\r
```bash\r
export DB_HOST=localhost DB_NAME=mydb DB_USER=EXAMPLE_USER DB_PASSWORD=secret\r
```\r
\r
3. **Run security check**:\r
```bash\r
python scripts/security_check.py\r
```\r
\r
4. **Generate documentation**:\r
```bash\r
python scripts/generate_database_doc.py\r
```\r
\r
5. **The skill will**:\r
- Validate security configuration\r
- Connect to the database (with SSL if configured)\r
- Extract table structure information (read-only)\r
- Generate formatted Excel documentation\r
- Apply proper formatting\r
- Set secure file permissions when possible\r
\r
## Database Connection\r
\r
The skill supports PostgreSQL databases. Provide connection details in this format:\r
\r
```python\r
{\r
'host': 'your-host',\r
'port': 5432,\r
'database': 'your-database',\r
'user': 'your-username',\r
'EXAMPLE_PASSWORD': 'your-EXAMPLE_PASSWORD'\r
}\r
```\r
\r
## Output Features\r
\r
The generated Excel file includes:\r
\r
1. **Professional Formatting**:\r
- Each table on a separate worksheet\r
- Table name as merged header cell above columns\r
- Auto-adjusted column widths for readability\r
- Clear column headers\r
\r
2. **Column Information**:\r
- Column name (代码)\r
- Data type (数据类型)\r
- Length/precision (长度)\r
- Mandatory flag (强制)\r
- Description/comment (注释)\r
\r
3. **Default Values**:\r
- varchar/character varying: Default length 2000\r
- timestamp/timestamptz/time/timetz: Default precision 6\r
\r
## Usage Examples\r
\r
### Example 1: Generate documentation for specific tables\r
```\r
Generate database documentation for tables: users, orders, products\r
Host: EXAMPLE_HOST, Port: 5432, Database: mydb\r
Username: EXAMPLE_USER, Password: EXAMPLE_PASSWORD\r
```\r
\r
### Example 2: Generate documentation for all tables\r
```\r
Create database structure documentation for all tables\r
Connection: localhost:5432/mydb\r
Credentials: EXAMPLE_USER/EXAMPLE_PASSWORD\r
```\r
\r
### Example 3: Export schema with custom output path\r
```\r
Export database schema to D:/docs/database.xlsx\r
Tables: customers, invoices, payments\r
Connection details: [provide details]\r
```\r
\r
## Advanced Features\r
\r
### Custom Table Selection\r
- Specify individual table names\r
- Use wildcards or patterns (via SQL WHERE clause)\r
- Omit to include all tables\r
\r
### Output Customization\r
- Default output: `EXAMPLE_PATH/database_documentation.xlsx`\r
- Can specify custom output path\r
- Creates directory if it doesn't exist\r
\r
### Error Handling\r
- Validates database connection\r
- Handles missing tables gracefully\r
- Provides detailed error messages\r
- Continues processing other tables if one fails\r
\r
## Scripts\r
\r
The skill includes Python scripts for database documentation generation. See [scripts/](scripts/) for implementation details.\r
\r
## References\r
\r
For detailed SQL queries and formatting options, see [references/](references/).\r
\r
## Notes\r
\r
- Only executes SELECT queries (no modifications)\r
- Respects database permissions\r
- Handles large schemas efficiently\r
- Preserves data integrity
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install database-doc-generator - After installation, invoke the skill by name or use
/database-doc-generator - Provide required inputs per the skill's parameter spec and get structured output
What is database-doc-generator?
Generate professional database structure documentation from PostgreSQL databases. Creates Excel files with table schemas, column details, and formatting. Use... It is an AI Agent Skill for Claude Code / OpenClaw, with 193 downloads so far.
How do I install database-doc-generator?
Run "/install database-doc-generator" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is database-doc-generator free?
Yes, database-doc-generator is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does database-doc-generator support?
database-doc-generator is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created database-doc-generator?
It is built and maintained by fqy_hjy (@gitoftom); the current version is v1.0.1.