quickdbd-cli 0.1.3__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/.gitignore +1 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/PKG-INFO +89 -22
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/README.md +85 -21
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/pyproject.toml +2 -1
- quickdbd_cli-0.1.5/src/quickdbd_cli/__init__.py +1 -0
- quickdbd_cli-0.1.5/src/quickdbd_cli/assets/render.js +512 -0
- quickdbd_cli-0.1.5/src/quickdbd_cli/assets/style.css +192 -0
- quickdbd_cli-0.1.5/src/quickdbd_cli/assets/viewer.js +761 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/cli.py +162 -9
- quickdbd_cli-0.1.5/src/quickdbd_cli/diff.py +247 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/export.py +23 -2
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/html.py +30 -6
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/layout.py +54 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/measure.py +21 -1
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/project.py +48 -2
- quickdbd_cli-0.1.5/tests/test_diff.py +127 -0
- quickdbd_cli-0.1.5/tests/test_path.py +67 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/tests/test_pipeline.py +109 -0
- quickdbd_cli-0.1.5/tests/test_select.py +143 -0
- quickdbd_cli-0.1.3/src/quickdbd_cli/__init__.py +0 -1
- quickdbd_cli-0.1.3/src/quickdbd_cli/assets/render.js +0 -241
- quickdbd_cli-0.1.3/src/quickdbd_cli/assets/style.css +0 -92
- quickdbd_cli-0.1.3/src/quickdbd_cli/assets/viewer.js +0 -380
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/LICENSE +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/NOTICE +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/examples/quickdbd-sample.txt +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/examples/synthetic/finance.txt +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/examples/synthetic/hr.txt +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/examples/synthetic/inventory.txt +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/examples/synthetic/marketing.txt +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/examples/synthetic/qdbd.layout.json +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/examples/synthetic/sales.txt +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/scripts/gen_font_metrics.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/scripts/gen_schema.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/scripts/release.sh +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/__main__.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/Inter-Bold.ttf +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/Inter-Bold.woff2 +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/Inter-LICENSE.txt +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/Inter-Regular.ttf +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/Inter-Regular.woff2 +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/editor.js +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/elk-LICENSE.md +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/elk.bundled.js +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/assets/font-metrics.json +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/dbt.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/jsrt.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/model.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/parser.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/src/quickdbd_cli/serve.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/tests/fixtures/jaffle/LICENSE +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/tests/fixtures/jaffle/README.md +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/tests/fixtures/jaffle/catalog.json +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/tests/fixtures/jaffle/manifest.json +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/tests/test_dbt.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/tests/test_parser.py +0 -0
- {quickdbd_cli-0.1.3 → quickdbd_cli-0.1.5}/tests/test_serve.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: quickdbd-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Compile QuickDBD-syntax schema files into interactive HTML ER diagrams, with no table limit.
|
|
5
5
|
Project-URL: Homepage, https://github.com/MarkPhamm/quickdbd-cli
|
|
6
6
|
Author: Minh (Mark) Pham
|
|
@@ -21,6 +21,9 @@ Provides-Extra: dev
|
|
|
21
21
|
Requires-Dist: fonttools>=4.50; extra == 'dev'
|
|
22
22
|
Requires-Dist: pytest>=8; extra == 'dev'
|
|
23
23
|
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
24
|
+
Provides-Extra: docs
|
|
25
|
+
Requires-Dist: mkdocs-material<10,>=9.5; extra == 'docs'
|
|
26
|
+
Requires-Dist: mkdocs<2,>=1.6; extra == 'docs'
|
|
24
27
|
Description-Content-Type: text/markdown
|
|
25
28
|
|
|
26
29
|
# quickdbd-cli (`qdbd`)
|
|
@@ -44,19 +47,25 @@ pipx install quickdbd-cli # or: uvx --from quickdbd-cli qdbd ...
|
|
|
44
47
|
qdbd build schema.txt -o schema.html
|
|
45
48
|
```
|
|
46
49
|
|
|
50
|
+
**Docs:** https://markphamm.github.io/quickdbd-cli/ · **Live demo (200 tables):** https://markphamm.github.io/quickdbd-cli/demo/
|
|
51
|
+
|
|
47
52
|
Not affiliated with QuickDBD. It reads the same text syntax, so schemas move freely between the two.
|
|
48
53
|
|
|
49
54
|
## Features
|
|
50
55
|
|
|
51
56
|
- **Same syntax as QuickDBD:** tables, aliases, quoted names, all 9 relationship operators, `rel` lines, PK/FK/NULL/UNIQUE/INDEX/IDENTITY, `default=`, doc comments, `[settings]` and `[layout]` sections. Error messages are QuickDBD's own.
|
|
52
57
|
- **Interactive page:**
|
|
53
|
-
- search
|
|
58
|
+
- explorer sidebar: tables grouped by file or dbt folder, with search (`/`, Enter jumps to the best match)
|
|
59
|
+
- table detail panel (dbt-docs style, for relationships): description, columns with type/keys/docs, and clickable **References** / **Referenced by** lists
|
|
54
60
|
- minimap
|
|
55
61
|
- click a table to focus on it and its neighbours
|
|
56
62
|
- collapse tables: full / keys only / names only
|
|
57
63
|
- hover a column to highlight its relationship
|
|
58
64
|
- hover a dotted-underlined table or column to read its `#` doc comments
|
|
59
|
-
- PNG/SVG export buttons
|
|
65
|
+
- PNG/SVG export buttons, and **draw.io**: an editable diagrams.net file using draw.io's ER table shapes and crow's-foot arrows
|
|
66
|
+
- **Path finder:** in a table's detail panel, type another table to see the shortest join path, highlighted on the canvas, with a ready-to-paste SQL `JOIN` (also `qdbd path erd/ --from payments --to customers`)
|
|
67
|
+
- **Regions:** a shaded, labelled area per file or dbt folder (toolbar toggle). `--by-group` on `build` / `export` / `layout` arranges tables so each folder sits together
|
|
68
|
+
- shareable links: the URL keeps the filter, selected table, collapse mode and zoom; **Link** copies it
|
|
60
69
|
- **Live editing:** `qdbd serve` reloads when you save, has a browser editor pane with autosave, and remembers where you drag tables.
|
|
61
70
|
- **Many files, one diagram:** point it at a folder and foreign keys can cross files.
|
|
62
71
|
- **Pip-only install:** no Graphviz, Node or browser needed. Layout uses [ELK](https://eclipse.dev/elk/), running in an embedded V8.
|
|
@@ -82,15 +91,55 @@ qdbd build erd/ -o erd.html
|
|
|
82
91
|
|
|
83
92
|
Re-running the import overwrites the generated files. Table positions survive because they live in the layout file, keyed by table name.
|
|
84
93
|
|
|
94
|
+
## Selecting tables
|
|
95
|
+
|
|
96
|
+
Like dbt's `--select`, but it follows relationships instead of lineage. It works in the page's filter box and as `-s/--select` / `--exclude` on `build` and `export`.
|
|
97
|
+
|
|
98
|
+
| Selector | Tables |
|
|
99
|
+
|---|---|
|
|
100
|
+
| `orders` / `stg_*` | by name or alias (glob, case-insensitive) |
|
|
101
|
+
| `+orders` | `orders` and every table it references (any depth); `1+orders` limits to one hop |
|
|
102
|
+
| `orders+` | `orders` and every table that references it; `orders+2` limits to two hops |
|
|
103
|
+
| `+orders+1` | both directions |
|
|
104
|
+
| `group:marts` | a file or dbt folder (and its subfolders) |
|
|
105
|
+
| `file:core.txt` | a schema file (glob) |
|
|
106
|
+
| `col:customer_id` | tables with a matching column |
|
|
107
|
+
| `diff:modified` / `diff:added` / `diff:changed` | changed since `--diff-base` (like dbt `state:modified`) |
|
|
108
|
+
| `a b` / `a,b` / `!a` | union / intersection / exclude |
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
qdbd build erd/ -s 'group:marts' --exclude '*_tmp' -o marts.html
|
|
112
|
+
qdbd export erd/ -s '+orders+1' -o orders.png
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Schema diffs
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
qdbd diff old.txt new.txt # two versions
|
|
119
|
+
qdbd diff --base origin/main erd/ # git ref vs working tree
|
|
120
|
+
qdbd diff --base origin/main erd/ --format markdown -o diff.md # for a PR comment
|
|
121
|
+
qdbd build erd/ --diff-base origin/main -o erd.html # colour what changed
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`diff` reports tables added and removed, column changes (added, removed, type and flag changes) and relationships added and removed. `--format json` is available, and `--exit-code` exits 1 when anything changed.
|
|
125
|
+
|
|
126
|
+
With `--diff-base`, the page:
|
|
127
|
+
- marks new tables green and changed tables amber, with a bar on each changed column;
|
|
128
|
+
- shows a summary banner, and its **Show changes** link filters to the changes plus their neighbours;
|
|
129
|
+
- lists each table's changes in the detail panel.
|
|
130
|
+
|
|
131
|
+
The selector `diff:modified` (or `diff:added` / `diff:changed`) works like dbt's `state:modified`, e.g. `-s 'diff:modified+1'`.
|
|
132
|
+
|
|
85
133
|
## Commands
|
|
86
134
|
|
|
87
135
|
```bash
|
|
88
136
|
qdbd check PATH... [--strict] # validate; "No errors found. Good job!"
|
|
89
|
-
qdbd build PATH... -o diagram.html # shareable interactive HTML
|
|
137
|
+
qdbd build PATH... -o diagram.html # shareable interactive HTML
|
|
90
138
|
qdbd serve PATH... [--port 8765] # live editor + drag-to-arrange
|
|
91
|
-
qdbd export PATH... -o out.png [--focus Customer --depth 1] # PNG or
|
|
139
|
+
qdbd export PATH... -o out.png [--focus Customer --depth 1] # PNG, SVG or .drawio
|
|
92
140
|
qdbd layout PATH... [--reset] # (re)write the layout file
|
|
93
141
|
qdbd import dbt target/manifest.json -o erd/ # generate schema files from a dbt project
|
|
142
|
+
qdbd path PATH... --from A --to B # shortest join path + SQL JOIN snippet
|
|
94
143
|
```
|
|
95
144
|
|
|
96
145
|
`PATH` is a `.txt` file or a folder. Every `*.txt` under a folder is read recursively.
|
|
@@ -123,27 +172,45 @@ Once a layout exists, a new table is placed next to the tables it's related to,
|
|
|
123
172
|
|
|
124
173
|
## CI
|
|
125
174
|
|
|
175
|
+
**GitHub Action:** checks the schema and builds the diagram. On pull requests it also posts one schema-diff comment, updated on every push, and highlights the changes in the diagram artifact.
|
|
176
|
+
|
|
177
|
+
```yaml
|
|
178
|
+
name: ERD
|
|
179
|
+
on: [pull_request, push]
|
|
180
|
+
jobs:
|
|
181
|
+
erd:
|
|
182
|
+
runs-on: ubuntu-latest
|
|
183
|
+
permissions: { contents: read, pull-requests: write }
|
|
184
|
+
steps:
|
|
185
|
+
- uses: actions/checkout@v4
|
|
186
|
+
- uses: MarkPhamm/quickdbd-cli@v0.1.5
|
|
187
|
+
with:
|
|
188
|
+
path: erd/ # schema file(s) or folder(s)
|
|
189
|
+
output: site/index.html
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
| Input | Default | |
|
|
193
|
+
|---|---|---|
|
|
194
|
+
| `path` | (required) | schema files or folders |
|
|
195
|
+
| `output` | `erd/index.html` | HTML diagram path |
|
|
196
|
+
| `check` / `strict` | `true` / `false` | fail on errors / also on QuickDBD-compatibility warnings |
|
|
197
|
+
| `comment` | `true` | post the diff comment on PRs |
|
|
198
|
+
| `select` | | dbt-style selector for the diagram |
|
|
199
|
+
| `qdbd-version` | `latest` | PyPI version |
|
|
200
|
+
|
|
201
|
+
Outputs are `html`, `changed` and `diff-file`.
|
|
202
|
+
|
|
203
|
+
**Publishing:** to publish the diagram on GitHub Pages, add `actions/upload-pages-artifact` + `actions/deploy-pages` after it. See [`.github/workflows/erd.yml`](.github/workflows/erd.yml), which publishes this repo's demo.
|
|
204
|
+
|
|
126
205
|
**pre-commit:**
|
|
127
206
|
|
|
128
207
|
```yaml
|
|
129
208
|
repos:
|
|
130
209
|
- repo: https://github.com/MarkPhamm/quickdbd-cli
|
|
131
|
-
rev: v0.1.
|
|
210
|
+
rev: v0.1.5
|
|
132
211
|
hooks:
|
|
133
212
|
- id: qdbd-check
|
|
134
|
-
files: ^
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
**GitHub Actions:**
|
|
138
|
-
|
|
139
|
-
```yaml
|
|
140
|
-
- uses: actions/setup-python@v5
|
|
141
|
-
with: { python-version: "3.12" }
|
|
142
|
-
- run: pip install quickdbd-cli
|
|
143
|
-
- run: qdbd check schema/
|
|
144
|
-
- run: qdbd build schema/ -o site/schema.html
|
|
145
|
-
- uses: actions/upload-artifact@v4
|
|
146
|
-
with: { name: schema-diagram, path: site/schema.html }
|
|
213
|
+
files: ^erd/.*\.txt$ # point at your schema files
|
|
147
214
|
```
|
|
148
215
|
|
|
149
216
|
**GitLab CI:**
|
|
@@ -153,10 +220,10 @@ erd:
|
|
|
153
220
|
image: python:3.12
|
|
154
221
|
script:
|
|
155
222
|
- pip install quickdbd-cli
|
|
156
|
-
- qdbd check
|
|
157
|
-
- qdbd build
|
|
223
|
+
- qdbd check erd/
|
|
224
|
+
- qdbd build erd/ -o public/index.html
|
|
158
225
|
artifacts:
|
|
159
|
-
paths: [public/
|
|
226
|
+
paths: [public/index.html]
|
|
160
227
|
```
|
|
161
228
|
|
|
162
229
|
## Development
|
|
@@ -19,19 +19,25 @@ pipx install quickdbd-cli # or: uvx --from quickdbd-cli qdbd ...
|
|
|
19
19
|
qdbd build schema.txt -o schema.html
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
**Docs:** https://markphamm.github.io/quickdbd-cli/ · **Live demo (200 tables):** https://markphamm.github.io/quickdbd-cli/demo/
|
|
23
|
+
|
|
22
24
|
Not affiliated with QuickDBD. It reads the same text syntax, so schemas move freely between the two.
|
|
23
25
|
|
|
24
26
|
## Features
|
|
25
27
|
|
|
26
28
|
- **Same syntax as QuickDBD:** tables, aliases, quoted names, all 9 relationship operators, `rel` lines, PK/FK/NULL/UNIQUE/INDEX/IDENTITY, `default=`, doc comments, `[settings]` and `[layout]` sections. Error messages are QuickDBD's own.
|
|
27
29
|
- **Interactive page:**
|
|
28
|
-
- search
|
|
30
|
+
- explorer sidebar: tables grouped by file or dbt folder, with search (`/`, Enter jumps to the best match)
|
|
31
|
+
- table detail panel (dbt-docs style, for relationships): description, columns with type/keys/docs, and clickable **References** / **Referenced by** lists
|
|
29
32
|
- minimap
|
|
30
33
|
- click a table to focus on it and its neighbours
|
|
31
34
|
- collapse tables: full / keys only / names only
|
|
32
35
|
- hover a column to highlight its relationship
|
|
33
36
|
- hover a dotted-underlined table or column to read its `#` doc comments
|
|
34
|
-
- PNG/SVG export buttons
|
|
37
|
+
- PNG/SVG export buttons, and **draw.io**: an editable diagrams.net file using draw.io's ER table shapes and crow's-foot arrows
|
|
38
|
+
- **Path finder:** in a table's detail panel, type another table to see the shortest join path, highlighted on the canvas, with a ready-to-paste SQL `JOIN` (also `qdbd path erd/ --from payments --to customers`)
|
|
39
|
+
- **Regions:** a shaded, labelled area per file or dbt folder (toolbar toggle). `--by-group` on `build` / `export` / `layout` arranges tables so each folder sits together
|
|
40
|
+
- shareable links: the URL keeps the filter, selected table, collapse mode and zoom; **Link** copies it
|
|
35
41
|
- **Live editing:** `qdbd serve` reloads when you save, has a browser editor pane with autosave, and remembers where you drag tables.
|
|
36
42
|
- **Many files, one diagram:** point it at a folder and foreign keys can cross files.
|
|
37
43
|
- **Pip-only install:** no Graphviz, Node or browser needed. Layout uses [ELK](https://eclipse.dev/elk/), running in an embedded V8.
|
|
@@ -57,15 +63,55 @@ qdbd build erd/ -o erd.html
|
|
|
57
63
|
|
|
58
64
|
Re-running the import overwrites the generated files. Table positions survive because they live in the layout file, keyed by table name.
|
|
59
65
|
|
|
66
|
+
## Selecting tables
|
|
67
|
+
|
|
68
|
+
Like dbt's `--select`, but it follows relationships instead of lineage. It works in the page's filter box and as `-s/--select` / `--exclude` on `build` and `export`.
|
|
69
|
+
|
|
70
|
+
| Selector | Tables |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `orders` / `stg_*` | by name or alias (glob, case-insensitive) |
|
|
73
|
+
| `+orders` | `orders` and every table it references (any depth); `1+orders` limits to one hop |
|
|
74
|
+
| `orders+` | `orders` and every table that references it; `orders+2` limits to two hops |
|
|
75
|
+
| `+orders+1` | both directions |
|
|
76
|
+
| `group:marts` | a file or dbt folder (and its subfolders) |
|
|
77
|
+
| `file:core.txt` | a schema file (glob) |
|
|
78
|
+
| `col:customer_id` | tables with a matching column |
|
|
79
|
+
| `diff:modified` / `diff:added` / `diff:changed` | changed since `--diff-base` (like dbt `state:modified`) |
|
|
80
|
+
| `a b` / `a,b` / `!a` | union / intersection / exclude |
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
qdbd build erd/ -s 'group:marts' --exclude '*_tmp' -o marts.html
|
|
84
|
+
qdbd export erd/ -s '+orders+1' -o orders.png
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Schema diffs
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
qdbd diff old.txt new.txt # two versions
|
|
91
|
+
qdbd diff --base origin/main erd/ # git ref vs working tree
|
|
92
|
+
qdbd diff --base origin/main erd/ --format markdown -o diff.md # for a PR comment
|
|
93
|
+
qdbd build erd/ --diff-base origin/main -o erd.html # colour what changed
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`diff` reports tables added and removed, column changes (added, removed, type and flag changes) and relationships added and removed. `--format json` is available, and `--exit-code` exits 1 when anything changed.
|
|
97
|
+
|
|
98
|
+
With `--diff-base`, the page:
|
|
99
|
+
- marks new tables green and changed tables amber, with a bar on each changed column;
|
|
100
|
+
- shows a summary banner, and its **Show changes** link filters to the changes plus their neighbours;
|
|
101
|
+
- lists each table's changes in the detail panel.
|
|
102
|
+
|
|
103
|
+
The selector `diff:modified` (or `diff:added` / `diff:changed`) works like dbt's `state:modified`, e.g. `-s 'diff:modified+1'`.
|
|
104
|
+
|
|
60
105
|
## Commands
|
|
61
106
|
|
|
62
107
|
```bash
|
|
63
108
|
qdbd check PATH... [--strict] # validate; "No errors found. Good job!"
|
|
64
|
-
qdbd build PATH... -o diagram.html # shareable interactive HTML
|
|
109
|
+
qdbd build PATH... -o diagram.html # shareable interactive HTML
|
|
65
110
|
qdbd serve PATH... [--port 8765] # live editor + drag-to-arrange
|
|
66
|
-
qdbd export PATH... -o out.png [--focus Customer --depth 1] # PNG or
|
|
111
|
+
qdbd export PATH... -o out.png [--focus Customer --depth 1] # PNG, SVG or .drawio
|
|
67
112
|
qdbd layout PATH... [--reset] # (re)write the layout file
|
|
68
113
|
qdbd import dbt target/manifest.json -o erd/ # generate schema files from a dbt project
|
|
114
|
+
qdbd path PATH... --from A --to B # shortest join path + SQL JOIN snippet
|
|
69
115
|
```
|
|
70
116
|
|
|
71
117
|
`PATH` is a `.txt` file or a folder. Every `*.txt` under a folder is read recursively.
|
|
@@ -98,27 +144,45 @@ Once a layout exists, a new table is placed next to the tables it's related to,
|
|
|
98
144
|
|
|
99
145
|
## CI
|
|
100
146
|
|
|
147
|
+
**GitHub Action:** checks the schema and builds the diagram. On pull requests it also posts one schema-diff comment, updated on every push, and highlights the changes in the diagram artifact.
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
name: ERD
|
|
151
|
+
on: [pull_request, push]
|
|
152
|
+
jobs:
|
|
153
|
+
erd:
|
|
154
|
+
runs-on: ubuntu-latest
|
|
155
|
+
permissions: { contents: read, pull-requests: write }
|
|
156
|
+
steps:
|
|
157
|
+
- uses: actions/checkout@v4
|
|
158
|
+
- uses: MarkPhamm/quickdbd-cli@v0.1.5
|
|
159
|
+
with:
|
|
160
|
+
path: erd/ # schema file(s) or folder(s)
|
|
161
|
+
output: site/index.html
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| Input | Default | |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| `path` | (required) | schema files or folders |
|
|
167
|
+
| `output` | `erd/index.html` | HTML diagram path |
|
|
168
|
+
| `check` / `strict` | `true` / `false` | fail on errors / also on QuickDBD-compatibility warnings |
|
|
169
|
+
| `comment` | `true` | post the diff comment on PRs |
|
|
170
|
+
| `select` | | dbt-style selector for the diagram |
|
|
171
|
+
| `qdbd-version` | `latest` | PyPI version |
|
|
172
|
+
|
|
173
|
+
Outputs are `html`, `changed` and `diff-file`.
|
|
174
|
+
|
|
175
|
+
**Publishing:** to publish the diagram on GitHub Pages, add `actions/upload-pages-artifact` + `actions/deploy-pages` after it. See [`.github/workflows/erd.yml`](.github/workflows/erd.yml), which publishes this repo's demo.
|
|
176
|
+
|
|
101
177
|
**pre-commit:**
|
|
102
178
|
|
|
103
179
|
```yaml
|
|
104
180
|
repos:
|
|
105
181
|
- repo: https://github.com/MarkPhamm/quickdbd-cli
|
|
106
|
-
rev: v0.1.
|
|
182
|
+
rev: v0.1.5
|
|
107
183
|
hooks:
|
|
108
184
|
- id: qdbd-check
|
|
109
|
-
files: ^
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
**GitHub Actions:**
|
|
113
|
-
|
|
114
|
-
```yaml
|
|
115
|
-
- uses: actions/setup-python@v5
|
|
116
|
-
with: { python-version: "3.12" }
|
|
117
|
-
- run: pip install quickdbd-cli
|
|
118
|
-
- run: qdbd check schema/
|
|
119
|
-
- run: qdbd build schema/ -o site/schema.html
|
|
120
|
-
- uses: actions/upload-artifact@v4
|
|
121
|
-
with: { name: schema-diagram, path: site/schema.html }
|
|
185
|
+
files: ^erd/.*\.txt$ # point at your schema files
|
|
122
186
|
```
|
|
123
187
|
|
|
124
188
|
**GitLab CI:**
|
|
@@ -128,10 +192,10 @@ erd:
|
|
|
128
192
|
image: python:3.12
|
|
129
193
|
script:
|
|
130
194
|
- pip install quickdbd-cli
|
|
131
|
-
- qdbd check
|
|
132
|
-
- qdbd build
|
|
195
|
+
- qdbd check erd/
|
|
196
|
+
- qdbd build erd/ -o public/index.html
|
|
133
197
|
artifacts:
|
|
134
|
-
paths: [public/
|
|
198
|
+
paths: [public/index.html]
|
|
135
199
|
```
|
|
136
200
|
|
|
137
201
|
## Development
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quickdbd-cli"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.5"
|
|
8
8
|
description = "Compile QuickDBD-syntax schema files into interactive HTML ER diagrams, with no table limit."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -25,6 +25,7 @@ dependencies = [
|
|
|
25
25
|
|
|
26
26
|
[project.optional-dependencies]
|
|
27
27
|
dev = ["pytest>=8", "ruff>=0.6", "fonttools>=4.50"]
|
|
28
|
+
docs = ["mkdocs>=1.6,<2", "mkdocs-material>=9.5,<10"]
|
|
28
29
|
|
|
29
30
|
[project.scripts]
|
|
30
31
|
qdbd = "quickdbd_cli.cli:main"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.5"
|