ERD exporter with PlantUML and mermaid format
$ ./plant_erd sqlite3 --database /path/to/test_db.sqlite3
entity articles {
* id : integer
--
* user_id : integer
--
index_user_id_on_articles (user_id)
}
entity users {
* id : integer
--
name : text
}
articles }-- users
$ ./plant_erd sqlite3 --database /path/to/test_db.sqlite3 --format=mermaid --show-comment
erDiagram
articles {
INTEGER id PK
INTEGER user_id FK
}
users {
INTEGER id PK
TEXT name
}
users ||--o{ articles : owns
erDiagram
articles {
INTEGER id PK
INTEGER user_id FK
}
users {
INTEGER id PK
TEXT name
}
users ||--o{ articles : owns
- Output ERD from real database
- Output ERD to stdout or file
- Output only tables within a certain distance adjacent to each other with foreign keys from a specific table
- SQLite3
- MySQL: 5.6, 5.7, 8
- PostgreSQL: 9, 10, 11, 12, 13, 14, 15
- Oracle
Download latest binary from https://github.com/sue445/plant_erd/releases and chmod 755
plant_erd
: for SQLite3, MySQL and PostgreSQLplant_erd-oracle
: for Oracle
plant_erd-oracle
requires Basic Package or Basic Light Package in Oracle Instant Client
mkdir -p /opt/oracle
wget --quiet --tries=0 https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-basiclite-linux.x64-19.3.0.0.0dbru.zip
unzip -q instantclient-basiclite-linux.x64-19.3.0.0.0dbru.zip -d /opt/oracle
export LD_LIBRARY_PATH=/opt/oracle/instantclient_19_3
# for Ubuntu
apt-get update
apt-get install -y libaio1
See https://github.com/kubo/ruby-oci8/blob/master/docs/install-on-osx.md and install instantclient-basic
or instantclient-basiclite
Also, you can install with https://github.com/InstantClientTap/homebrew-instantclient
e.g.
brew install InstantClientTap/instantclient/instantclient-basiclite
OCI8_PREFIX="$(brew --prefix)/lib/"
echo $OCI8_PREFIX
vi oci8.pc
oci8.pc
is following. (Replace __REPLACE_WITH_OCI8_PREFIX__
with $OCI8_PREFIX
)
prefix=__REPLACE_WITH_OCI8_PREFIX__
libdir=${prefix}
includedir=${prefix}/sdk/include/
Name: oci8
Description: Oracle Instant Client
Version: 19.8
Libs: -L${libdir} -lclntsh
Libs.private:
Cflags: -I${includedir}
cp oci8.pc "$(brew --prefix)/lib/pkgconfig/"
- Go to https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html
- Download
instantclient-basic-windows.x64-19.5.0.0.0dbru.zip
orinstantclient-basiclite-windows.x64-19.5.0.0.0dbru.zip
- Extract zip
- Move
plant_erd-oracle
to same directory asoci.dll
$ ./plant_erd sqlite3 --help
NAME:
plant_erd sqlite3 - Generate ERD from sqlite3
USAGE:
plant_erd sqlite3 [options]
OPTIONS:
--database DATABASE SQLite3 DATABASE file
--distance DISTANCE, -d DISTANCE Output only tables within a certain DISTANCE adjacent to each other with foreign keys from a specific table (default: 0)
--file FILE, -f FILE FILE for output (default: stdout)
--format string Output format (plant_uml, mermaid. default:plant_uml)
--show-comment Show column comment. This option is used only --format=mermaid (default: false)
--skip-index, -i Whether don't print index to ERD. This option is used only --format=plant_uml (default: false)
--skip-table string, -s string Skip generating table by using regex patterns
--table TABLE, -t TABLE Output only tables within a certain distance adjacent to each other with foreign keys from a specific TABLE
--help, -h show help
$ ./plant_erd mysql --help
NAME:
plant_erd mysql - Generate ERD from mysql
USAGE:
plant_erd mysql [options]
OPTIONS:
--collation COLLATION MySQL COLLATION (default: "utf8_general_ci")
--database DATABASE MySQL DATABASE name
--distance DISTANCE, -d DISTANCE Output only tables within a certain DISTANCE adjacent to each other with foreign keys from a specific table (default: 0)
--file FILE, -f FILE FILE for output (default: stdout)
--format string Output format (plant_uml, mermaid. default:plant_uml)
--host HOST MySQL HOST (default: "localhost")
--password PASSWORD MySQL PASSWORD [$MYSQL_PASSWORD]
--port PORT MySQL PORT (default: 3306)
--show-comment Show column comment. This option is used only --format=mermaid (default: false)
--skip-index, -i Whether don't print index to ERD. This option is used only --format=plant_uml (default: false)
--skip-table string, -s string Skip generating table by using regex patterns
--table TABLE, -t TABLE Output only tables within a certain distance adjacent to each other with foreign keys from a specific TABLE
--user USER MySQL USER (default: "root")
--help, -h show help
$ ./plant_erd postgresql --help
NAME:
plant_erd postgresql - Generate ERD from PostgreSQL
USAGE:
plant_erd postgresql [options]
OPTIONS:
--database DATABASE PostgreSQL DATABASE name
--distance DISTANCE, -d DISTANCE Output only tables within a certain DISTANCE adjacent to each other with foreign keys from a specific table (default: 0)
--file FILE, -f FILE FILE for output (default: stdout)
--format string Output format (plant_uml, mermaid. default:plant_uml)
--host HOST PostgreSQL HOST (default: "localhost")
--password PASSWORD PostgreSQL PASSWORD [$POSTGRES_PASSWORD]
--port PORT PostgreSQL PORT (default: 5432)
--show-comment Show column comment. This option is used only --format=mermaid (default: false)
--skip-index, -i Whether don't print index to ERD. This option is used only --format=plant_uml (default: false)
--skip-table string, -s string Skip generating table by using regex patterns
--sslmode SSLMODE PostgreSQL SSLMODE. c.f. https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS (default: "disable")
--table TABLE, -t TABLE Output only tables within a certain distance adjacent to each other with foreign keys from a specific TABLE
--user USER PostgreSQL USER
--help, -h show help
$ ./plant_erd-oracle --help
NAME:
plant_erd-oracle - ERD exporter with PlantUML and Mermaid format (for oracle)
USAGE:
plant_erd-oracle [global options]
VERSION:
vX.X.X (build. xxxxxxx)
GLOBAL OPTIONS:
--file FILE, -f FILE FILE for output (default: stdout)
--table TABLE, -t TABLE Output only tables within a certain distance adjacent to each other with foreign keys from a specific TABLE
--distance DISTANCE, -d DISTANCE Output only tables within a certain DISTANCE adjacent to each other with foreign keys from a specific table (default: 0)
--skip-index, -i Whether don't print index to ERD. This option is used only --format=plant_uml (default: false)
--skip-table string, -s string Skip generating table by using regex patterns
--format string Output format (plant_uml, mermaid. default:plant_uml)
--show-comment Show column comment. This option is used only --format=mermaid (default: false)
--user USER Oracle USER
--password PASSWORD Oracle PASSWORD [$ORACLE_PASSWORD]
--host HOST Oracle HOST (default: "localhost")
--port PORT Oracle PORT (default: 1521)
--service SERVICE Oracle SERVICE name
--help, -h show help
--version, -v print the version
When --table
and --distance
are passed, output only tables within a certain distance adjacent to each other with foreign keys from a specific table.
$ ./plant_erd sqlite3
$ ./plant_erd sqlite3 --table articles --distance 1
Run test in container
docker-compose up --build --abort-on-container-exit
Run test on local
make test
The program is available as open source under the terms of the MIT License.
But plant_erd-oracle
contains Oracle Instant Client.
Oracle Instant Client is under OTN License.