This program produces diagrams of graphs where the nodes are tables and the edges are foreign-key relations. There is a small query language to specify the tables that should be included in the diagram.
Using the Pagila schema as an example:
pgviz --out pagila.svg "(graph (within 2 (table film)))"
produces
The query language uses s-expressions and includes the following functions:
graph <q: query> <s0: subgraph> ...- produces a
graphwith top level nodes matchingqand any number of included subgraphs subgraph <label: string> <g: graph> ...- produces a
subgraphwith the provided label that contains the provided graph within <n: integer> <q: query>- produces a
querythat includes all tables withinnedges of tables matchingq schema <s: schema name> ...- produces a
querythat includes all tables contained by the provided schemas table <t: table name> ...- procudes a
querythat includes tables whose name is equal to any of the provided table names and <q0: query> <q1: query> ...- produces a
querythat include tables that match all of the provided queries or <q0: query> <q1: query> ...- produces a
querythat includes tables that match any of the provided queries - <lhs: query> <rhs: query>- produces a
querythat includes tables that matchlhs, but do not matchrhs
Columns have background colors that indicate certain attributes, for example: nullable columns are gray, unique columns are green, primary key columns are blue, columns that are both nullable and unique are a darker green.
cd into src and cargo build as usual. graphviz is a runtime dependency.
nix build will compile the binary that references a nix-pinned graphviz. You
can also run it directly with
nix run "github:tstat/pgviz" -- <args>
or add it to your nix registry with
nix registry add pgviz "github:tstat/pgviz"
then you can run it with nix run pgviz -- <args>