Render a graphical representation of a MySQL or SQLite database from a mysqldump
or sqlite3
.dump
file.
- 2013/09
- Version 1.0 released:
- Uses
/usr/bin/env/php
in shebang line to improve portability - Fixes new PHP versions' now-deprecated
split()
withexplode()
- Silences warnings on modern PHP default configurations related to array indices handling
- Uses
- Version 1.0 released:
- ~2009
- Version 0.3 released:
- Now with sqlite support
- Version 0.3 released:
- Can infer foreign key relationships if you do not have them defined
- Handles partial dumps (FK to tables that are not defined within the dump)
- Fast! Uses sed and grep for data extraction (MySQL only)
This output was generated from the input file https://raw.githubusercontent.com/globalcitizen/mysqlviz/master/eg.sql.
port install mysqlviz
sudo apt-get install -y graphviz
Then install code from here.
sudo emerge graphviz
Then install code from here.
[mysqlviz - mysql + sqlite database visualisation tool]
usage:
./mysqlviz -f <sqldumpfile> [-r]
^--- 'redump' mode: generates a
mysqldump command line to redump.
toolchain:
$ mysqldump -d db >db.sql # MySQL: -d = 'no data', only structure
- OR -
$ sqlite database.db .dump >db.sql # SQLite (also: 'sqlite3 ...')
$ ./mysqlviz -f ./db.sql >./db.dot # 'dot' is a graphviz format.
$ dot -Tpng db.dot >db.png # generate image with graphviz
notes:
if you do not have any foreign keys defined, relationships will be
assumed in cases where a column name ends in one of (id/ID/_id/_ID) and
there is a matching table (for example, onetable.othertable_ID column, and
othertable is defined). the program will also match tables with
various prefixes and suffixes.
Written in PHP. Uses sed
and grep
for speed, and graphviz
as the graph renderer. Tested with output from MySQL 5.0 and SQLite 3.7.2 on PHP v4.x through 5.4.x
- Cutesy diamonds etc. to denote relationship types
- Testing against dumps from older/newer MySQL versions (eg. MariaDB)
- Options for modifying the complexity of output (column types, relationship type, etc.)