Output ER diagram from PostgreSQL with SchemaSpy 6.1.0

It describes how to output ER diagram using SchemaSpy with one command, so I think this is more convenient! https://qiita.com/ap8322/items/b93dfb2ff29b026ffa72

(Updated on May 25, 2020)

Introduction

Since ER diagram was sometimes output by SchemaSpy, I will leave the output method. Also, starting with Schemespy 6.1.0 (latest as of March 12, 2019), Graphviz is no longer required to be installed, and ER diagrams can be output simply by adding the -vizjs option.

Prerequisite environment

Download SchemaSpy 6.1.0

Download 6.1.0 from "Latest Build" on Github https://github.com/schemaspy/schemaspy The latest schema spy can only be downloaded from here. Is the stable version 6.0.0?

Download the JDBC driver for PostgreSQL

A driver for PostgreSQL is required to connect to PostgreSQL from SchemaSpy. As of March 12, 2019, postgresql-42.2.5.jar was up to date. URL where the driver can be downloaded ↓ https://jdbc.postgresql.org/

Preparing a working directory

Arrange the files as shown below and generate the result output destination directory.

[Arbitrary directory name]
├── postgresql-42.2.5.jar
├── result (Schema spy result output directory)
└── schemaspy-6.1.0-SNAPSHOT.jar

Generating and editing schemaspy.properties

Write a configuration file that is read by default when schemaspy is run. (It is designed to read schemaspy.properties by default.)

vi schemaspy.properties

schemaspy.properties


# type of database. Run with -dbhelp for details
schemaspy.t=pgsql
# optional path to alternative jdbc drivers.
schemaspy.dp=./postgresql-42.2.5.jar
# database properties: host, port number, name user, password
schemaspy.host=Any host(ex: localhost)
schemaspy.port=Any port(ex: 5432)
schemaspy.db=Arbitrary database name
schemaspy.u=Arbitrary username
# output dir to save generated files
schemaspy.o=./result/
# db scheme for which generate diagrams
schemaspy.s=public

Run schemaspy

java -jar schemaspy-6.1.0-SNAPSHOT.jar -vizjs

The point is to add **-vizjs **.

After that, you can check the result by opening result / index.html. Easy!

in conclusion

What did you think? Since ER can be output easily, it is useful when tools such as phpMyAdmin cannot be installed!

Happy Coding!

Recommended Posts

Output ER diagram from PostgreSQL with SchemaSpy 6.1.0
How to output standard from an array with forEach
Output table from Map <String, Object> format with Thymeleaf3
Output FizzBuzz with stream
How to automatically generate ER diagram when migrating with Rails6