datakiln.show_graph module¶
Shows the dependency graph of the tables and derive scripts.
- datakiln.show_graph.is_schema(node) bool[source]¶
Whether the node is a script that creates a schema.
- Parameters:
node (datakiln.metadata.table.TableMeta | datakiln.metadata.script.ScriptMeta) – Table or script.
- Return type:
bool
- datakiln.show_graph.label(node) List[str][source]¶
Lines to tell a node by: its name, and the file of a script if the name does not tell it.
- Parameters:
node (datakiln.metadata.table.TableMeta | datakiln.metadata.script.ScriptMeta) – Table or script.
- Return type:
list[str]
- datakiln.show_graph.edges(graph: DatabaseGraph, nodes: Iterable) List[tuple][source]¶
Pairs of two tables or two scripts where the second one needs the first. There are none between a table and a script.
An arrow is left out if the nodes are also linked through other nodes. If c needs b and b needs a, then c needs a through b, so the pairs are (a, b) and (b, c) but not (a, c).
- Parameters:
graph (datakiln.metadata.graph.DatabaseGraph) – Dependency graph.
nodes (Iterable) – Nodes that can be shown.
- Return type:
list[tuple]
- datakiln.show_graph.select(graph: DatabaseGraph, include: Iterable[str] = None, schemas: bool = False) List[source]¶
Nodes to show, ordered by name: the ones that have an arrow, as the others would only be a row of boxes, and the ones asked for.
- Parameters:
graph (datakiln.metadata.graph.DatabaseGraph) – Dependency graph.
include (Iterable[str]) – Names of the nodes to show, with the nodes they need. All by default.
schemas (bool) – Whether to show the scripts that create schemas, which every script of the schema needs.
- Raises:
ValueError – If any of the names is not a node.
- Return type:
list
- datakiln.show_graph.mermaid(graph: DatabaseGraph, nodes: List, direction: str = 'LR') str[source]¶
Graph as a Mermaid flowchart, which GitLab and GitHub draw in a Markdown file.
- Parameters:
graph (datakiln.metadata.graph.DatabaseGraph) – Dependency graph.
nodes (list) – Nodes shown, in order.
direction (str) – Direction of the flow, LR or TB.
- Return type:
str
- datakiln.show_graph.markdown(graph: DatabaseGraph, nodes: List, direction: str = 'LR') str[source]¶
Graph as a Markdown document, which GitLab and GitHub draw when it is opened.
- Parameters:
graph (datakiln.metadata.graph.DatabaseGraph) – Dependency graph.
nodes (list) – Nodes shown, in order.
direction (str) – Direction of the flow, LR or TB.
- Return type:
str
- datakiln.show_graph.html(graph: DatabaseGraph, nodes: List, direction: str = 'LR') str[source]¶
Graph as a web page, which any browser draws. The page loads Mermaid from the internet.
- Parameters:
graph (datakiln.metadata.graph.DatabaseGraph) – Dependency graph.
nodes (list) – Nodes shown, in order.
direction (str) – Direction of the flow, LR or TB.
- Return type:
str