Show HN: Auto DB Diagram – An ERD generator for relational databases

4 months ago 3

This tool was built to solve the pains of maintaining database diagrams on software projects such as regularly having to make new diagrams and dealing with descrepancies between your diagrams and your actual databases. Just download the tool, pass it your database info, and let it handle the diagrams!

Example of a generated PNG

To install on Mac or Linux:

The code can be run in headless mode, in which case, you must pass the file path to a config file:

db-diagram --headless /Users/jamesdaniel/automatic-db-digrammer/config.json db-diagram -h /Users/jamesdaniel/automatic-db-digrammer/config.json

The structure of valid config files varies based on the type of database you want to connect to, but examples can be found under /configs_examples/valid_configs. In addition to examples, here is a slightly more formal explanation of the permitted fields in the config file, depending on the database you are trying to connect to.

postgresConfig { database_type: "postgres" connection_info: { host: string; port: number; username: string; database_name: string; password?: string; }; excluded_tables?: string[]; }
SQLiteConfig { database_type: "sqlite" connection_info: { database_location: string; }; excluded_tables?: string[]; }

Note: a question mark denotes an optional field, any fields included but not listed will be ignored.

Alternatively, the program can be run in interactive mode, where it will walk you through the setup:

This tool currently supports connections to local postgreSQL instances and SQLite instances.

  • MySQL connections
  • SQL Server Connections
  • Hosted DB Connections
Read Entire Article