Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
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 [[https://github.com/devrimgunduz/pagila][Pagila]] schema as an example: #+begin_src pgviz --out pagila.svg "(graph (within 2 (table film)))" #+end_src 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 #+begin_src nix run "github:tstat/pgviz" -- <args> #+end_src or add it to your nix registry with #+begin_src nix registry add pgviz "github:tstat/pgviz" #+end_src then you can run it with ~nix run pgviz -- <args>~