Skip to content

CLI

The CLI entry points are db2md and python -m db2md.

Examples

# List databases (skips system catalogs by default)
db2md --url 'postgresql+asyncpg://user:pass@localhost:5432/postgres' --list

# Document every non-system database → ./schemas/<db>.md
db2md --url 'postgresql+asyncpg://user:pass@localhost:5432/postgres'

# Specific databases / output path
db2md \
  --url 'postgresql+asyncpg://user:pass@localhost:5432/postgres' \
  -d myapp -d analytics \
  -o ./docs/db

# Include system databases when listing
db2md --url 'postgresql+asyncpg://user:pass@localhost:5432/postgres' \
  --include-system --list

# Verbose logging
db2md --url 'sqlite+aiosqlite:///./app.db' -v -o ./schemas

# Nullable columns as a native `type?` suffix instead of a "nullable" comment
db2md --url 'sqlite+aiosqlite:///./app.db' --er-style optional

Options

Flag Description
-u, --url SQLAlchemy URL (or set DATABASE_URL)
-o, --output Output directory (default: schemas/), or a file when documenting a single -d
-d, --database Database to document (repeatable). Default: all non-system DBs
--schema Schema/namespace (default: dialect-specific — public for PostgreSQL)
--er-style ER attribute style: compat (default), optional, minimal — see Output format
--list List databases and exit
--include-system Include system databases
-v, --verbose Debug logging
--version Show version
-h, --help Show help

Exit codes

Code Meaning
0 Success
1 Connection failure, no databases found, or export error

Environment

Variable Role
DATABASE_URL Used when --url is omitted