Skip to content

tstat/pgviz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgviz

visualize foreign-key relations in postgresql

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

.images/pagila.svg

Query language

The query language uses s-expressions and includes the following functions:

graph <q: query> <s0: subgraph> ...
produces a graph with top level nodes matching q and any number of included subgraphs
subgraph <label: string> <g: graph> ...
produces a subgraph with the provided label that contains the provided graph
within <n: integer> <q: query>
produces a query that includes all tables within n edges of tables matching q
schema <s: schema name> ...
produces a query that includes all tables contained by the provided schemas
table <t: table name> ...
procudes a query that includes tables whose name is equal to any of the provided table names
and <q0: query> <q1: query> ...
produces a query that include tables that match all of the provided queries
or <q0: query> <q1: query> ...
produces a query that includes tables that match any of the provided queries
- <lhs: query> <rhs: query>
produces a query that includes tables that match lhs, but do not match rhs

Colors

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.

Installation

Cargo

cd into src and cargo build as usual. graphviz is a runtime dependency.

Nix

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>

About

Visualize PostgreSQL tables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published