Xpersona
D

database-doc-generator

CLAWHUB · Unverified

Generate professional database structure documentation from PostgreSQL databases. Creates Excel files with table schemas, column details, and formatting. Use... Skill: database-doc-generator Owner: gitoftom Summary: Generate professional database structure documentation from PostgreSQL databases. Creates Excel files with table schemas, column details, and formatting. Use... Tags: latest:1.0.1 Version history: v1.0.1 | 2026-03-25T01:25:51.566Z | user **Security-focused update with new scripts and installation guidance** - Major security upgrades: explicit warnings, secure cre

62
Rank
84
Safety
997
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 997 downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s1787ph9he718q62yes7xb2ggd83j4pq:database-doc-generator
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-gitoftom-database-doc-generator/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

90,189 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: database-doc-generator
description: 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".
---

# Database Documentation Generator

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.

## ⚠️ SECURITY WARNING

**IMPORTANT SECURITY NOTES:**

1. **Never commit real database credentials** to source control
2. **Use environment variables** or secure configuration files for credentials
3. **Review all database connections** before use
4. **This skill requires network access** to PostgreSQL databases
5. **Install dependencies manually** - automatic installation is disabled for security

## Security-First Installation & Usage

### Installation Method: Instruction-Only (No Auto-Download)

This skill uses a **secure instruction-only installation model**:
- ✅ No automatic code downloads
- ✅ No archive extraction
- ✅ No arbitrary URL fetching
- ✅ No elevated permissions required

### Step 1: Secure Environment Setup

```bash
# Method A: Virtual Environment (RECOMMENDED)
python -m venv venv-database-docs
source venv-database-docs/bin/activate  # On Windows: venv-database-docs\Scripts\activate

# Method B: With pinned versions for security
pip install -r requirements.txt

# Method C: Manual installation
pip install psycopg2-binary==2.9.9 pandas==2.2.1 openpyxl==3.1.2
```

### Step 2: Security Validation (MANDATORY)

```bash
# Run comprehensive security check
python scripts/security_check.py

# Expected output: "SECURITY CHECK PASSED"
# If warnings appear, review and fix before proceeding
```

### Step 2: Set Secure Credentials
**NEVER hardcode credentials. Use environment variables:**

```bash
# Set credentials via environment variables (RECOMMENDED)
export DB_HOST=your-actual-host
export DB_PORT=5432
export DB_NAME=your-actual-database
export DB_USER=your-actual-username
export DB_PASSWORD=your-actual-EXAMPLE_PASSWORD

# Optional: Enable SSL for secure connections
export DB_SSLMODE=require
```

### Step 3: Generate Documentation Securely
```bash
# Method A: Using environment variables (most secure)
python scripts/generate_database_doc.py

# Method B: With command-line arguments
python scripts/generate_database_doc.py \
  --host your-host \
  --database your-db \
  --user your-user \
  --EXAMPLE_PASSWORD your-EXAMPLE_PASSWORD

# Method C: Using secure config file
python scripts/generate_database_doc.py --confi

README.md

# Database Documentation Generator

A professional OpenClaw skill for generating database structure documentation from PostgreSQL databases.

## Features

- 📊 **Professional Excel Output**: Creates formatted Excel files with table schemas
- 🎨 **Automatic Formatting**: Merged headers, auto-adjusted column widths, professional styling
- 🔗 **PostgreSQL Support**: Extracts structure information from PostgreSQL databases
- 📝 **Complete Documentation**: Includes column names, data types, lengths, constraints, and comments
- ⚙️ **Easy Configuration**: Simple JSON configuration for database connection
- 🛡️ **Error Handling**: Robust error handling and detailed logging

## ⚠️ Security-First Installation

This skill uses **instruction-only installation** - no code is automatically downloaded or executed. This significantly reduces security risks.

### Installation Methods (Choose One)

#### Method A: Virtual Environment (RECOMMENDED)
```bash
# Create isolated environment
python -m venv venv-database-docs
source venv-database-docs/bin/activate  # On Windows: venv-database-docs\Scripts\activate

# Install with pinned versions for security
pip install psycopg2-binary==2.9.9 pandas==2.2.1 openpyxl==3.1.2
```

#### Method B: System Installation (Use with Caution)
```bash
# Install with user privileges only
pip install --user psycopg2-binary pandas openpyxl
```

#### Method C: Docker (Most Secure)
```dockerfile
# Dockerfile
FROM python:3.9-slim
RUN pip install psycopg2-binary pandas openpyxl
COPY . .
```

### Security Verification
```bash
# Run security check before use
python scripts/security_check.py

# Test with validation only
python scripts/generate_database_doc.py --validate-only
```

## Quick Start

1. **Set credentials securely** (NEVER in source code):
   ```bash
   # Environment variables (recommended)
   export DB_HOST=your-actual-host
   export DB_NAME=your-actual-database
   export DB_USER=your-actual-username
   export DB_PASSWORD=your-actual-EXAMPLE_PASSWORD
   
   # Enable SSL for security
   export DB_SSLMODE=require
   ```

2. **Run security validation**:
   ```bash
   python scripts/security_check.py
   ```

3. **Generate documentation**:
   ```bash
   python scripts/generate_database_doc.py
   ```

4. **Use in OpenClaw**:
   ```
   Generate database documentation for delivery_record table
   ```

## Security Guidelines

### Mandatory Practices
1. **Never store credentials** in source files or version control
2. **Always use virtual environments** or containers for isolation
3. **Verify package integrity** before installation
4. **Use SSL/TLS** for all database connections

### Network Security
- Configure firewall rules for database access
- Use VPN or SSH tunneling for remote connections
- Implement database-level IP whitelisting

### Output Security
- Store generated files in secure directories
- Set restrictive file permissions
- Consider 

_meta.json

{
  "ownerId": "kn75qzn3nnkgkb408y5v7n9hkx839qp1",
  "slug": "database-doc-generator",
  "version": "1.0.1",
  "publishedAt": 1774401951566
}

references/EXCEL_FORMATTING.md

# Excel Formatting Guide

This document describes the Excel formatting applied by the Database Documentation Generator.

## Formatting Features

### 1. Merged Header Cell
- **Location**: Row 1, Columns A-E
- **Content**: `表: {table_name}`
- **Style**: Bold, size 14, centered
- **Purpose**: Clear table identification

### 2. Column Headers
- **Location**: Row 2
- **Columns**: 表名, 代码, 数据类型, 长度, 强制, 注释
- **Style**: Bold, size 12, centered, bordered
- **Purpose**: Clear column labels

### 3. Data Rows
- **Start**: Row 3
- **Style**: Size 10, vertically centered, bordered
- **Purpose**: Readable data presentation

### 4. Auto-Adjusted Column Widths
- **Method**: Calculates maximum content length per column
- **Padding**: +2 characters
- **Maximum**: 50 characters
- **Purpose**: Optimal readability without excessive width

### 5. Row Heights
- **Header Row (1)**: 30 points
- **Column Headers (2)**: 25 points
- **Data Rows**: Auto (default)

## Formatting Code

```python
from openpyxl.styles import Alignment, Font, Border, Side
from openpyxl.utils import get_column_letter

def apply_excel_formatting(writer, table_name, df):
    # Get workbook and worksheet
    workbook = writer.book
    worksheet = writer.sheets[table_name[:31]]
    
    # Define styles
    header_font = Font(bold=True, size=12)
    header_alignment = Alignment(horizontal='center', vertical='center')
    data_font = Font(size=10)
    data_alignment = Alignment(vertical='center')
    thin_border = Border(
        left=Side(style='thin'),
        right=Side(style='thin'),
        top=Side(style='thin'),
        bottom=Side(style='thin')
    )
    
    # Merge cells for table name
    worksheet.merge_cells(start_row=1, start_column=1, end_row=1, end_column=5)
    table_name_cell = worksheet.cell(row=1, column=1)
    table_name_cell.value = f"表: {table_name}"
    table_name_cell.font = Font(bold=True, size=14)
    table_name_cell.alignment = Alignment(horizontal='center', vertical='center')
    
    # Format column headers
    for col_num, column_title in enumerate(df.columns, 1):
        cell = worksheet.cell(row=2, column=col_num)
        cell.font = header_font
        cell.alignment = header_alignment
        cell.border = thin_border
    
    # Format data rows
    for row in range(3, worksheet.max_row + 1):
        for col in range(1, worksheet.max_column + 1):
            cell = worksheet.cell(row=row, column=col)
            cell.font = data_font
            cell.alignment = data_alignment
            cell.border = thin_border
    
    # Auto-adjust column widths
    for column in worksheet.columns:
        max_length = 0
        column_letter = get_column_letter(column[0].column)
        
        for cell in column[1:]:  # Skip merged header
            try:
                if cell.value:
                    cell_length = len(str(cell.value))
                    if cell_length > max_length:
   

references/SQL_QUERIES.md

# SQL Queries for Database Documentation

This document contains the SQL queries used by the Database Documentation Generator skill.

## Main Structure Query

The primary query extracts column information from PostgreSQL's information_schema:

```sql
SELECT
 a.column_name AS 代码,
 udt_name AS 数据类型,
 CASE
 WHEN udt_name IN ('varchar', 'character varying') AND COALESCE(character_maximum_length, -999) = -999 THEN '2000'
 WHEN udt_name IN ('timestamp', 'timestamptz', 'time', 'timetz') AND COALESCE(datetime_precision, -999) = -999 THEN '6'
 ELSE
 (CASE
 WHEN COALESCE(character_maximum_length, -999) = -999 THEN 
   CASE 
   WHEN numeric_precision IS NOT NULL THEN numeric_precision::text
   WHEN datetime_precision IS NOT NULL THEN datetime_precision::text
   ELSE NULL
   END
 ELSE character_maximum_length::text
 END)||(CASE
 WHEN udt_name IN ('numeric', 'decimal') THEN ','||COALESCE(numeric_scale::text, '0')
 ELSE '' 
 END)
 END AS 长度,

 CASE
 WHEN is_nullable = 'YES' THEN 'FALSE'
 ELSE 'TRUE'
 END AS 强制,
 col_description(b.oid, a.ordinal_position) AS 注释
FROM
 information_schema.columns AS a
 LEFT JOIN
 pg_class AS b ON a.table_name = b.relname
 LEFT JOIN
 information_schema.key_column_usage AS pk ON a.table_name = pk.table_name AND a.column_name = pk.column_name
 LEFT JOIN
 information_schema.table_constraints AS tc ON pk.constraint_name = tc.constraint_name
WHERE
 a.table_name = %s
ORDER BY
 a.table_schema,
 a.table_name,
 a.ordinal_position;
```

## Default Values

### varchar/character varying
- Default length: 2000
- Applied when: `character_maximum_length` is NULL or -999

### timestamp/timestamptz/time/timetz
- Default precision: 6
- Applied when: `datetime_precision` is NULL or -999

### numeric/decimal
- Format: `precision,scale` (e.g., `10,2`)
- Scale defaults to 0 if NULL

## Table List Query

Get all tables in the public schema:

```sql
SELECT table_name 
FROM information_schema.tables 
WHERE table_schema = 'public' 
AND table_type = 'BASE TABLE'
ORDER BY table_name;
```

## Column Types Mapping

PostgreSQL to Excel type mapping:

| PostgreSQL Type | Excel Display | Notes |
|----------------|---------------|-------|
| int8, int4, int2 | int8, int4, int2 | Integer types |
| varchar, text | varchar | Character types |
| timestamp, timestamptz | timestamp | Date/time types |
| numeric, decimal | numeric | Decimal numbers |
| bool | bool | Boolean |
| json, jsonb | json | JSON data |
| uuid | uuid | UUID |

## Performance Considerations

1. **Large Schemas**: The query is optimized for performance but may be slow on databases with thousands of tables
2. **Caching**: Consider caching results for frequently accessed schemas
3. **Permissions**: Ensure the database user has read access to information_schema

## Security Considerations

### Query Safety
- This skill only executes **SELECT** queries against `information_schema`
- No data modification (I

Sponsored

Ads related to database-doc-generator and adjacent AI workflows.