Registry / database / postgerd

postgerd

JSON →
library1.0.7jsnpmunverified

PostgERD is a CLI tool that connects to a PostgreSQL database using environment variables and generates Entity-Relationship Diagram (ERD) SVG images, or outputs PlantUML and nomnoml files. Version 1.0.7 is latest as of writing, with no regular release cadence. It supports multiple database schemas and relies on dotenv for loading credentials. Differentiators: generates diagrams directly from live PostgreSQL schemas without manual modeling; outputs three formats (SVG, PlantUML, nomnoml). Note that foreign key connections across schemas are only supported in PlantUML output.

npm install postgerd
INSTALL
IMPORT
SIG · POSTGERD
P
postgerd
databasejavascriptv1.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

postgerd
npx postgerd -o output.svg
npm run postgerd (unless script defined)
PostgERD is a CLI tool, not a library. Use npx or install globally.
npx
npx postgerd -o diagram.svg
postgerd (if not installed globally)
Recommended usage via npx to avoid global install.
CLI flags
npx postgerd --schema public --plantuml
npx postgerd -s public --plantuml (no short flag for schema)
Use --schema for schema filter; short flags are -o for output only.

Connects to PostgreSQL using environment variables and generates an ERD SVG, or alternate formats, with optional schema restriction.

# Ensure PostgreSQL connection environment variables are set (DATABASE_URL or PGUSER, PGPASSWORD, PGHOST, PGDATABASE) export DATABASE_URL="postgresql://user:password@localhost:5432/mydb" # Or create a .env file with DATABASE_URL # Then run: npx postgerd -o my_erd.svg # Optionally specify a single schema: npx postgerd -o my_erd.svg --schema public # Output PlantUML: npx postgerd -o my_erd.plantuml --plantuml # Output nomnoml: npx postgerd -o my_erd.nomnoml --nomnoml
Debug
Known issues
gotchaForeign key connections across schemas are only supported in PlantUML output, not in SVG or nomnoml.
fix
Use --plantuml option if you need cross-schema foreign key relationships.
affects: <=1.0.7
gotchaEnvironment variables must be set (DATABASE_URL or PGUSER, PGPASSWORD, etc.). Without them, the command will fail.
fix
Ensure required environment variables are set or create a .env file with DATABASE_URL.
affects: <=1.0.7
gotchaIf using a .env file, it must be in the current working directory where the command is run; dotenv does not automatically traverse parents.
fix
Run command from the directory containing .env or specify path via dotenv options (not supported by postgerd).
affects: <=1.0.7
deprecatedThe package uses CommonJS require internally but may be run as ESM via npx. No formal deprecation.
fix
No fix needed; it works in both contexts.
affects: <=1.0.7
Errors
Common errors & fixes
Error: Cannot find module 'pg'
Missing runtime dependency 'pg'
fix
Install postgres client: npm install pg
Error: getaddrinfo ENOTFOUND localhost
PostgreSQL host is not reachable (e.g., wrong host in environment variable).
fix
Check connection string or environment variables: echo $DATABASE_URL
Error: relation "..." does not exist
Schema filter restricts to non-existent schema or tables are in different schema.
fix
List available schemas: `npx postgerd` without --schema, or use correct schema name.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
dotenvrequiredUsed to load PostgreSQL connection environment variables from .env files
pgrequiredPostgreSQL client for Node.js to connect and query the database
Agent activity
4 hits · last 30 days
node
4
Resources
postgerd — npm install postgerd · libregistry