quickdbd-cli 0.1.10__tar.gz → 0.1.12__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.10 → quickdbd_cli-0.1.12}/NOTICE +13 -0
- quickdbd_cli-0.1.12/PKG-INFO +249 -0
- quickdbd_cli-0.1.12/README.md +221 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/pyproject.toml +2 -2
- quickdbd_cli-0.1.12/scripts/build_gallery.py +265 -0
- quickdbd_cli-0.1.12/scripts/gen_thumbnails.py +106 -0
- quickdbd_cli-0.1.12/src/quickdbd_cli/__init__.py +1 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/dbt.py +1 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_dbt.py +14 -0
- quickdbd_cli-0.1.12/tests/test_gallery.py +109 -0
- quickdbd_cli-0.1.10/PKG-INFO +0 -485
- quickdbd_cli-0.1.10/README.md +0 -457
- quickdbd_cli-0.1.10/src/quickdbd_cli/__init__.py +0 -1
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/.gitignore +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/LICENSE +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/examples/quickdbd-sample.txt +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/examples/synthetic/finance.txt +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/examples/synthetic/hr.txt +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/examples/synthetic/inventory.txt +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/examples/synthetic/marketing.txt +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/examples/synthetic/qdbd.layout.json +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/examples/synthetic/sales.txt +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/scripts/gen_font_metrics.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/scripts/gen_schema.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/scripts/release.sh +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/__main__.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/Inter-Bold.ttf +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/Inter-Bold.woff2 +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/Inter-LICENSE.txt +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/Inter-Regular.ttf +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/Inter-Regular.woff2 +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/editor.js +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/elk-LICENSE.md +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/elk.bundled.js +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/font-metrics.json +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/render.js +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/style.css +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/assets/viewer.js +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/cli.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/diff.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/export.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/html.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/jsrt.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/layout.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/measure.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/model.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/parser.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/project.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/serve.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/share.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/src/quickdbd_cli/tags.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/fixtures/jaffle/LICENSE +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/fixtures/jaffle/README.md +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/fixtures/jaffle/catalog.json +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/fixtures/jaffle/manifest.json +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_diff.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_parser.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_path.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_pipeline.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_select.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_serve.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_share.py +0 -0
- {quickdbd_cli-0.1.10 → quickdbd_cli-0.1.12}/tests/test_tags.py +0 -0
|
@@ -14,6 +14,19 @@ This product bundles third-party components, distributed unmodified:
|
|
|
14
14
|
Copyright The Inter Project Authors. Licensed under the SIL Open Font License 1.1
|
|
15
15
|
(src/quickdbd_cli/assets/Inter-LICENSE.txt). Source: https://github.com/rsms/inter
|
|
16
16
|
|
|
17
|
+
The demo gallery (gallery/, not part of the Python package) includes schemas derived from:
|
|
18
|
+
|
|
19
|
+
* Northwind and AdventureWorks (gallery/northwind, gallery/adventureworks), converted from
|
|
20
|
+
microsoft/sql-server-samples. Copyright (c) Microsoft Corporation. MIT License.
|
|
21
|
+
* Sakila (gallery/sakila), converted from sakila-schema.sql. Copyright (c) 2006, 2026, Oracle and/or
|
|
22
|
+
its affiliates. BSD-3-Clause.
|
|
23
|
+
* Chinook (gallery/chinook), converted from lerocha/chinook-database. Copyright (c) 2008-2024
|
|
24
|
+
Luis Rocha. MIT License.
|
|
25
|
+
* dbt-synthea (gallery/synthea), OHDSI. Apache License 2.0. Trimmed dbt manifest and catalog only.
|
|
26
|
+
* dbt_shopify (gallery/shopify), Fivetran. Apache License 2.0. Trimmed dbt manifest and catalog only.
|
|
27
|
+
|
|
28
|
+
Each folder keeps the upstream licence in its LICENSE file.
|
|
29
|
+
|
|
17
30
|
`qdbd serve` loads CodeMirror 5 (MIT) from cdnjs at runtime; it is not bundled.
|
|
18
31
|
|
|
19
32
|
QuickDBD is a product of its respective owners; this project is not affiliated with it.
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: quickdbd-cli
|
|
3
|
+
Version: 0.1.12
|
|
4
|
+
Summary: Compile QuickDBD-syntax schema files into interactive HTML ER diagrams, with no table limit.
|
|
5
|
+
Project-URL: Homepage, https://github.com/MarkPhamm/quickdbd-cli
|
|
6
|
+
Author: Minh (Mark) Pham
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
License-File: src/quickdbd_cli/assets/Inter-LICENSE.txt
|
|
11
|
+
License-File: src/quickdbd_cli/assets/elk-LICENSE.md
|
|
12
|
+
Keywords: database,diagram,erd,quickdbd,schema
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Database
|
|
16
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Requires-Dist: mini-racer>=0.14
|
|
19
|
+
Requires-Dist: resvg-py>=0.5
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: fonttools>=4.50; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
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'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<picture>
|
|
31
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/MarkPhamm/quickdbd-cli/main/docs/assets/img/logo-wordmark-dark.svg">
|
|
32
|
+
<img src="https://raw.githubusercontent.com/MarkPhamm/quickdbd-cli/main/docs/assets/img/logo-wordmark-light.svg" alt="qdbd" width="220">
|
|
33
|
+
</picture>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<p align="center"><b>Interactive ER diagrams from QuickDBD text or a dbt project, readable at 200+ tables</b></p>
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<a href="https://qdbd.dev/">Docs</a> · <a href="https://qdbd.dev/demo/">Live demos</a> · <a href="#quickstart">Quickstart</a> · <a href="https://pypi.org/project/quickdbd-cli/">PyPI</a>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
<p align="center">
|
|
43
|
+
<a href="https://qdbd.dev/demo/adventureworks/#t=SalesOrderHeader"><img src="https://raw.githubusercontent.com/MarkPhamm/quickdbd-cli/main/docs/assets/img/hero.png" alt="The AdventureWorks sample database as a qdbd diagram, with the SalesOrderHeader table selected" width="760"></a>
|
|
44
|
+
</p>
|
|
45
|
+
<p align="center">
|
|
46
|
+
<em>AdventureWorks (68 tables) with its column descriptions, built by qdbd. <a href="https://qdbd.dev/demo/adventureworks/#t=SalesOrderHeader">Try it live →</a></em>
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
## What is qdbd?
|
|
50
|
+
|
|
51
|
+
qdbd is a **command-line tool that turns a database schema written as text into an interactive ER diagram**.
|
|
52
|
+
|
|
53
|
+
- Diagrams drawn by hand look good, but they live outside the repo and go stale the first time the schema changes.
|
|
54
|
+
- Generated diagrams stay current, but most become unreadable past a few dozen tables.
|
|
55
|
+
|
|
56
|
+
With qdbd the schema is a plain-text file in git, written in [QuickDBD](https://www.quickdatabasediagrams.com)'s syntax or generated from a dbt project. qdbd checks it, lays it out, and builds **one self-contained HTML page** you can search, filter, click through and share.
|
|
57
|
+
|
|
58
|
+
You get **a diagram that lives next to your code** and **stays usable at hundreds of tables**.
|
|
59
|
+
|
|
60
|
+
qdbd is not affiliated with QuickDBD. It reads the same text syntax, so schemas copy back and forth between the two.
|
|
61
|
+
|
|
62
|
+
## Key features
|
|
63
|
+
|
|
64
|
+
- **QuickDBD-compatible**: the parser mirrors QuickDBD's own, error messages included. A file that passes `qdbd check --strict` pastes into QuickDBD unchanged.
|
|
65
|
+
- **dbt import**: `qdbd import dbt` reads `manifest.json`. Primary keys come from `unique` + `not_null` tests or constraints, relationships from `relationships` tests, and `--infer-fks` fills the gaps from column names.
|
|
66
|
+
- **Readable at 200+ tables**: automatic layout, search, dbt-style selectors (`+orders+1`, `group:marts`, `tag:fact`), shaded regions per file, collapsed views and a minimap.
|
|
67
|
+
- **Review changes in pull requests**: `qdbd diff` reports what a branch changed, the GitHub Action posts it as a PR comment, and `--diff-base` colours the changes in the diagram.
|
|
68
|
+
- **One schema, many outputs**: an HTML page, PNG, SVG, editable draw.io, or a shareable link. Installs with pip: no Node, Graphviz or browser needed.
|
|
69
|
+
|
|
70
|
+
## Demo gallery
|
|
71
|
+
|
|
72
|
+
Every demo is a single HTML page written by `qdbd build`, from a QuickDBD schema or a dbt manifest.
|
|
73
|
+
|
|
74
|
+
<!-- gallery:start: generated by `python scripts/build_gallery.py --readme` from gallery/demos.toml -->
|
|
75
|
+
| | |
|
|
76
|
+
|---|---|
|
|
77
|
+
| [](https://qdbd.dev/demo/synthetic/)<br>**[200 tables](https://qdbd.dev/demo/synthetic/)**<br>Five business domains, 200 tables and every relationship type. Search, filter, click a table to focus it. | [](https://qdbd.dev/demo/diff/)<br>**[Schema diff](https://qdbd.dev/demo/diff/)**<br>What a branch changed, coloured in: new tables in green, changed columns in amber, removals listed. |
|
|
78
|
+
| [](https://qdbd.dev/demo/adventureworks/)<br>**[AdventureWorks](https://qdbd.dev/demo/adventureworks/)**<br>Microsoft's bicycle-company OLTP database: 68 tables in five schemas, one region each, with column descriptions. | [](https://qdbd.dev/demo/synthea/#t=concept)<br>**[OMOP CDM on Synthea](https://qdbd.dev/demo/synthea/#t=concept)**<br>OHDSI's dbt-synthea: synthetic patient records mapped to the OMOP Common Data Model. 145 tables, 235 relationships from tests. |
|
|
79
|
+
|
|
80
|
+
[View all 14 demos →](https://qdbd.dev/demo/)
|
|
81
|
+
<!-- gallery:end -->
|
|
82
|
+
|
|
83
|
+
## Quickstart
|
|
84
|
+
|
|
85
|
+
### Fastest start: try it without installing
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
curl -O https://raw.githubusercontent.com/MarkPhamm/quickdbd-cli/main/examples/quickdbd-sample.txt
|
|
89
|
+
uvx --from quickdbd-cli qdbd serve quickdbd-sample.txt
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
A browser tab opens with the diagram and an editor. Change the text and the diagram reloads; drag tables to arrange them.
|
|
93
|
+
|
|
94
|
+
### Or step by step
|
|
95
|
+
|
|
96
|
+
#### 1. Install
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
pipx install quickdbd-cli # or: pip install quickdbd-cli / uv tool install quickdbd-cli
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Python 3.11+. See [Install](https://qdbd.dev/install/) for other options.
|
|
103
|
+
|
|
104
|
+
#### 2. Write a schema, or generate one from dbt
|
|
105
|
+
|
|
106
|
+
Save this as `schema.txt`, or paste in a schema from QuickDBD unchanged:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
Customer
|
|
110
|
+
-
|
|
111
|
+
CustomerId PK int
|
|
112
|
+
Email string UNIQUE
|
|
113
|
+
|
|
114
|
+
Order as o
|
|
115
|
+
----
|
|
116
|
+
OrderId PK int
|
|
117
|
+
CustomerId int FK >- Customer.CustomerId
|
|
118
|
+
Total decimal(10,2)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
A table is a name, a line of dashes, then one column per line. `FK >- Customer.CustomerId` means many orders to one customer. The full syntax is in [Schema Syntax](https://qdbd.dev/syntax/).
|
|
122
|
+
|
|
123
|
+
For a dbt project, generate the schema instead:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
dbt docs generate # writes target/manifest.json + catalog.json
|
|
127
|
+
qdbd import dbt target/ -o erd/ --infer-fks # one .txt file per dbt folder
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### 3. Edit it live
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
qdbd serve schema.txt
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Edit in the browser or in your own editor; the diagram reloads on save. Dragged positions are saved to `schema.layout.json`, which you commit next to the schema.
|
|
137
|
+
|
|
138
|
+
#### 4. Build, export and share
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
qdbd build schema.txt -o schema.html # one self-contained page
|
|
142
|
+
qdbd export schema.txt -o schema.png # or .svg, .drawio
|
|
143
|
+
qdbd share schema.txt # a link to the page, via a GitHub gist
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Run in CI
|
|
147
|
+
|
|
148
|
+
The GitHub Action checks the schema and builds the diagram. On pull requests it also posts one schema-diff comment, updated on every push.
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
# .github/workflows/erd.yml
|
|
152
|
+
name: ERD
|
|
153
|
+
on: [pull_request, push]
|
|
154
|
+
jobs:
|
|
155
|
+
erd:
|
|
156
|
+
runs-on: ubuntu-latest
|
|
157
|
+
permissions: { contents: read, pull-requests: write }
|
|
158
|
+
steps:
|
|
159
|
+
- uses: actions/checkout@v4
|
|
160
|
+
- uses: MarkPhamm/quickdbd-cli@v0.1.11
|
|
161
|
+
with:
|
|
162
|
+
path: erd/ # schema file(s) or folder(s)
|
|
163
|
+
output: site/index.html
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
dbt projects, GitHub Pages, pre-commit and GitLab CI are covered in [CI and Automation](https://qdbd.dev/github-action/).
|
|
167
|
+
|
|
168
|
+
## How qdbd works
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
dbt project ──qdbd import dbt──┐
|
|
172
|
+
├──▶ schema/*.txt (QuickDBD syntax, in git)
|
|
173
|
+
hand-written / pasted ─────────┘ │
|
|
174
|
+
├──▶ qdbd check validation, QuickDBD's error messages ──▶ CI gate
|
|
175
|
+
├──▶ qdbd serve live editor, drag to arrange ──▶ schema.layout.json
|
|
176
|
+
├──▶ qdbd build interactive HTML ──▶ GitHub Pages, artifacts
|
|
177
|
+
├──▶ qdbd diff what changed vs main ──▶ PR comment
|
|
178
|
+
└──▶ qdbd export PNG · SVG · draw.io ──▶ docs, slides, wikis
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- **The parser** follows QuickDBD's own parser step by step, so the same text gives the same tables and the same errors.
|
|
182
|
+
- **The layout** comes from [ELK](https://eclipse.dev/elk/). Positions you drag are saved by table name, and new tables are placed next to the tables they relate to, so the diagram doesn't reshuffle.
|
|
183
|
+
- **One renderer** draws both the page and the images. It runs in the browser, and inside an embedded JavaScript engine for CLI exports, so a PNG always matches the page.
|
|
184
|
+
- **Builds are deterministic**: no timestamps or randomness, so the output only changes when the schema does.
|
|
185
|
+
|
|
186
|
+
## What it looks like
|
|
187
|
+
|
|
188
|
+
**1. The schema**, a text file in your repo:
|
|
189
|
+
|
|
190
|
+
```text
|
|
191
|
+
# Every order belongs to one customer.
|
|
192
|
+
Order as o
|
|
193
|
+
----
|
|
194
|
+
OrderId PK int IDENTITY
|
|
195
|
+
CustomerId int FK >- Customer.CustomerId
|
|
196
|
+
Status string="pending" # current fulfilment state
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**2. The command:**
|
|
200
|
+
|
|
201
|
+
```sh
|
|
202
|
+
qdbd build schema/ -o erd.html
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**3. The page:** click a table for its columns, comments and relationships, or type another table's name to get the join path as SQL.
|
|
206
|
+
|
|
207
|
+

|
|
208
|
+
|
|
209
|
+
## qdbd and QuickDBD
|
|
210
|
+
|
|
211
|
+
| | qdbd | QuickDBD |
|
|
212
|
+
|---|---|---|
|
|
213
|
+
| Text syntax | QuickDBD's | QuickDBD's |
|
|
214
|
+
| Tables per diagram | no limit | 10 on the free plan |
|
|
215
|
+
| Where it runs | your terminal and CI; the result is a static HTML file | the QuickDBD web app |
|
|
216
|
+
| Where the schema lives | `.txt` files in your git repo | the web app |
|
|
217
|
+
| dbt import, schema diffs, PR comments | ✅ | — |
|
|
218
|
+
|
|
219
|
+
Use QuickDBD's editor when you want it: a schema that passes `qdbd check --strict` pastes in unchanged.
|
|
220
|
+
|
|
221
|
+
## FAQ
|
|
222
|
+
|
|
223
|
+
**Do I need a QuickDBD account?**
|
|
224
|
+
No. qdbd only borrows the text syntax.
|
|
225
|
+
|
|
226
|
+
**Does qdbd connect to my database?**
|
|
227
|
+
No. It reads `.txt` schema files or a dbt `manifest.json`. Nothing connects to a warehouse.
|
|
228
|
+
|
|
229
|
+
**Does my schema leave my machine?**
|
|
230
|
+
Only if you run `qdbd share`, which uploads the page to a GitHub gist in your account (secret by default). `qdbd serve` loads its code editor from a CDN; the built pages load nothing.
|
|
231
|
+
|
|
232
|
+
**How big can a diagram get?**
|
|
233
|
+
The demos go up to 200 tables. Search, selectors, regions and collapsed views keep large diagrams workable; `--select` builds a page with just the part you need.
|
|
234
|
+
|
|
235
|
+
**Can I edit the diagram by hand?**
|
|
236
|
+
You edit the text; the diagram is generated from it. Table positions are the one thing you arrange yourself, by dragging in `qdbd serve`.
|
|
237
|
+
|
|
238
|
+
## Learn more
|
|
239
|
+
|
|
240
|
+
- [Install](https://qdbd.dev/install/) and [Quick Start](https://qdbd.dev/getting-started/)
|
|
241
|
+
- [Schema Syntax](https://qdbd.dev/syntax/), [many files](https://qdbd.dev/files/), [table positions](https://qdbd.dev/layout/), [tags and colours](https://qdbd.dev/tags/)
|
|
242
|
+
- [Reading the Diagram](https://qdbd.dev/reading-the-diagram/), [selectors](https://qdbd.dev/selectors/), [exports](https://qdbd.dev/exports/), [sharing a link](https://qdbd.dev/sharing/)
|
|
243
|
+
- [dbt Projects](https://qdbd.dev/dbt/), with a [jaffle_shop walkthrough](https://qdbd.dev/example/)
|
|
244
|
+
- [Schema Diffs](https://qdbd.dev/diffs/), the [GitHub Action](https://qdbd.dev/github-action/) and the [CLI reference](https://qdbd.dev/cli/)
|
|
245
|
+
- [Development](https://qdbd.dev/development/): working on qdbd itself, releasing, and adding a demo
|
|
246
|
+
|
|
247
|
+
## License
|
|
248
|
+
|
|
249
|
+
Apache-2.0. Bundled third-party files (ELK, Inter) and the sources of the demo schemas are listed in [NOTICE](https://github.com/MarkPhamm/quickdbd-cli/blob/main/NOTICE).
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/MarkPhamm/quickdbd-cli/main/docs/assets/img/logo-wordmark-dark.svg">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/MarkPhamm/quickdbd-cli/main/docs/assets/img/logo-wordmark-light.svg" alt="qdbd" width="220">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center"><b>Interactive ER diagrams from QuickDBD text or a dbt project, readable at 200+ tables</b></p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://qdbd.dev/">Docs</a> · <a href="https://qdbd.dev/demo/">Live demos</a> · <a href="#quickstart">Quickstart</a> · <a href="https://pypi.org/project/quickdbd-cli/">PyPI</a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://qdbd.dev/demo/adventureworks/#t=SalesOrderHeader"><img src="https://raw.githubusercontent.com/MarkPhamm/quickdbd-cli/main/docs/assets/img/hero.png" alt="The AdventureWorks sample database as a qdbd diagram, with the SalesOrderHeader table selected" width="760"></a>
|
|
16
|
+
</p>
|
|
17
|
+
<p align="center">
|
|
18
|
+
<em>AdventureWorks (68 tables) with its column descriptions, built by qdbd. <a href="https://qdbd.dev/demo/adventureworks/#t=SalesOrderHeader">Try it live →</a></em>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
## What is qdbd?
|
|
22
|
+
|
|
23
|
+
qdbd is a **command-line tool that turns a database schema written as text into an interactive ER diagram**.
|
|
24
|
+
|
|
25
|
+
- Diagrams drawn by hand look good, but they live outside the repo and go stale the first time the schema changes.
|
|
26
|
+
- Generated diagrams stay current, but most become unreadable past a few dozen tables.
|
|
27
|
+
|
|
28
|
+
With qdbd the schema is a plain-text file in git, written in [QuickDBD](https://www.quickdatabasediagrams.com)'s syntax or generated from a dbt project. qdbd checks it, lays it out, and builds **one self-contained HTML page** you can search, filter, click through and share.
|
|
29
|
+
|
|
30
|
+
You get **a diagram that lives next to your code** and **stays usable at hundreds of tables**.
|
|
31
|
+
|
|
32
|
+
qdbd is not affiliated with QuickDBD. It reads the same text syntax, so schemas copy back and forth between the two.
|
|
33
|
+
|
|
34
|
+
## Key features
|
|
35
|
+
|
|
36
|
+
- **QuickDBD-compatible**: the parser mirrors QuickDBD's own, error messages included. A file that passes `qdbd check --strict` pastes into QuickDBD unchanged.
|
|
37
|
+
- **dbt import**: `qdbd import dbt` reads `manifest.json`. Primary keys come from `unique` + `not_null` tests or constraints, relationships from `relationships` tests, and `--infer-fks` fills the gaps from column names.
|
|
38
|
+
- **Readable at 200+ tables**: automatic layout, search, dbt-style selectors (`+orders+1`, `group:marts`, `tag:fact`), shaded regions per file, collapsed views and a minimap.
|
|
39
|
+
- **Review changes in pull requests**: `qdbd diff` reports what a branch changed, the GitHub Action posts it as a PR comment, and `--diff-base` colours the changes in the diagram.
|
|
40
|
+
- **One schema, many outputs**: an HTML page, PNG, SVG, editable draw.io, or a shareable link. Installs with pip: no Node, Graphviz or browser needed.
|
|
41
|
+
|
|
42
|
+
## Demo gallery
|
|
43
|
+
|
|
44
|
+
Every demo is a single HTML page written by `qdbd build`, from a QuickDBD schema or a dbt manifest.
|
|
45
|
+
|
|
46
|
+
<!-- gallery:start: generated by `python scripts/build_gallery.py --readme` from gallery/demos.toml -->
|
|
47
|
+
| | |
|
|
48
|
+
|---|---|
|
|
49
|
+
| [](https://qdbd.dev/demo/synthetic/)<br>**[200 tables](https://qdbd.dev/demo/synthetic/)**<br>Five business domains, 200 tables and every relationship type. Search, filter, click a table to focus it. | [](https://qdbd.dev/demo/diff/)<br>**[Schema diff](https://qdbd.dev/demo/diff/)**<br>What a branch changed, coloured in: new tables in green, changed columns in amber, removals listed. |
|
|
50
|
+
| [](https://qdbd.dev/demo/adventureworks/)<br>**[AdventureWorks](https://qdbd.dev/demo/adventureworks/)**<br>Microsoft's bicycle-company OLTP database: 68 tables in five schemas, one region each, with column descriptions. | [](https://qdbd.dev/demo/synthea/#t=concept)<br>**[OMOP CDM on Synthea](https://qdbd.dev/demo/synthea/#t=concept)**<br>OHDSI's dbt-synthea: synthetic patient records mapped to the OMOP Common Data Model. 145 tables, 235 relationships from tests. |
|
|
51
|
+
|
|
52
|
+
[View all 14 demos →](https://qdbd.dev/demo/)
|
|
53
|
+
<!-- gallery:end -->
|
|
54
|
+
|
|
55
|
+
## Quickstart
|
|
56
|
+
|
|
57
|
+
### Fastest start: try it without installing
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
curl -O https://raw.githubusercontent.com/MarkPhamm/quickdbd-cli/main/examples/quickdbd-sample.txt
|
|
61
|
+
uvx --from quickdbd-cli qdbd serve quickdbd-sample.txt
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A browser tab opens with the diagram and an editor. Change the text and the diagram reloads; drag tables to arrange them.
|
|
65
|
+
|
|
66
|
+
### Or step by step
|
|
67
|
+
|
|
68
|
+
#### 1. Install
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
pipx install quickdbd-cli # or: pip install quickdbd-cli / uv tool install quickdbd-cli
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Python 3.11+. See [Install](https://qdbd.dev/install/) for other options.
|
|
75
|
+
|
|
76
|
+
#### 2. Write a schema, or generate one from dbt
|
|
77
|
+
|
|
78
|
+
Save this as `schema.txt`, or paste in a schema from QuickDBD unchanged:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
Customer
|
|
82
|
+
-
|
|
83
|
+
CustomerId PK int
|
|
84
|
+
Email string UNIQUE
|
|
85
|
+
|
|
86
|
+
Order as o
|
|
87
|
+
----
|
|
88
|
+
OrderId PK int
|
|
89
|
+
CustomerId int FK >- Customer.CustomerId
|
|
90
|
+
Total decimal(10,2)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
A table is a name, a line of dashes, then one column per line. `FK >- Customer.CustomerId` means many orders to one customer. The full syntax is in [Schema Syntax](https://qdbd.dev/syntax/).
|
|
94
|
+
|
|
95
|
+
For a dbt project, generate the schema instead:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
dbt docs generate # writes target/manifest.json + catalog.json
|
|
99
|
+
qdbd import dbt target/ -o erd/ --infer-fks # one .txt file per dbt folder
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 3. Edit it live
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
qdbd serve schema.txt
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Edit in the browser or in your own editor; the diagram reloads on save. Dragged positions are saved to `schema.layout.json`, which you commit next to the schema.
|
|
109
|
+
|
|
110
|
+
#### 4. Build, export and share
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
qdbd build schema.txt -o schema.html # one self-contained page
|
|
114
|
+
qdbd export schema.txt -o schema.png # or .svg, .drawio
|
|
115
|
+
qdbd share schema.txt # a link to the page, via a GitHub gist
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Run in CI
|
|
119
|
+
|
|
120
|
+
The GitHub Action checks the schema and builds the diagram. On pull requests it also posts one schema-diff comment, updated on every push.
|
|
121
|
+
|
|
122
|
+
```yaml
|
|
123
|
+
# .github/workflows/erd.yml
|
|
124
|
+
name: ERD
|
|
125
|
+
on: [pull_request, push]
|
|
126
|
+
jobs:
|
|
127
|
+
erd:
|
|
128
|
+
runs-on: ubuntu-latest
|
|
129
|
+
permissions: { contents: read, pull-requests: write }
|
|
130
|
+
steps:
|
|
131
|
+
- uses: actions/checkout@v4
|
|
132
|
+
- uses: MarkPhamm/quickdbd-cli@v0.1.11
|
|
133
|
+
with:
|
|
134
|
+
path: erd/ # schema file(s) or folder(s)
|
|
135
|
+
output: site/index.html
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
dbt projects, GitHub Pages, pre-commit and GitLab CI are covered in [CI and Automation](https://qdbd.dev/github-action/).
|
|
139
|
+
|
|
140
|
+
## How qdbd works
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
dbt project ──qdbd import dbt──┐
|
|
144
|
+
├──▶ schema/*.txt (QuickDBD syntax, in git)
|
|
145
|
+
hand-written / pasted ─────────┘ │
|
|
146
|
+
├──▶ qdbd check validation, QuickDBD's error messages ──▶ CI gate
|
|
147
|
+
├──▶ qdbd serve live editor, drag to arrange ──▶ schema.layout.json
|
|
148
|
+
├──▶ qdbd build interactive HTML ──▶ GitHub Pages, artifacts
|
|
149
|
+
├──▶ qdbd diff what changed vs main ──▶ PR comment
|
|
150
|
+
└──▶ qdbd export PNG · SVG · draw.io ──▶ docs, slides, wikis
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- **The parser** follows QuickDBD's own parser step by step, so the same text gives the same tables and the same errors.
|
|
154
|
+
- **The layout** comes from [ELK](https://eclipse.dev/elk/). Positions you drag are saved by table name, and new tables are placed next to the tables they relate to, so the diagram doesn't reshuffle.
|
|
155
|
+
- **One renderer** draws both the page and the images. It runs in the browser, and inside an embedded JavaScript engine for CLI exports, so a PNG always matches the page.
|
|
156
|
+
- **Builds are deterministic**: no timestamps or randomness, so the output only changes when the schema does.
|
|
157
|
+
|
|
158
|
+
## What it looks like
|
|
159
|
+
|
|
160
|
+
**1. The schema**, a text file in your repo:
|
|
161
|
+
|
|
162
|
+
```text
|
|
163
|
+
# Every order belongs to one customer.
|
|
164
|
+
Order as o
|
|
165
|
+
----
|
|
166
|
+
OrderId PK int IDENTITY
|
|
167
|
+
CustomerId int FK >- Customer.CustomerId
|
|
168
|
+
Status string="pending" # current fulfilment state
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**2. The command:**
|
|
172
|
+
|
|
173
|
+
```sh
|
|
174
|
+
qdbd build schema/ -o erd.html
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**3. The page:** click a table for its columns, comments and relationships, or type another table's name to get the join path as SQL.
|
|
178
|
+
|
|
179
|
+

|
|
180
|
+
|
|
181
|
+
## qdbd and QuickDBD
|
|
182
|
+
|
|
183
|
+
| | qdbd | QuickDBD |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| Text syntax | QuickDBD's | QuickDBD's |
|
|
186
|
+
| Tables per diagram | no limit | 10 on the free plan |
|
|
187
|
+
| Where it runs | your terminal and CI; the result is a static HTML file | the QuickDBD web app |
|
|
188
|
+
| Where the schema lives | `.txt` files in your git repo | the web app |
|
|
189
|
+
| dbt import, schema diffs, PR comments | ✅ | — |
|
|
190
|
+
|
|
191
|
+
Use QuickDBD's editor when you want it: a schema that passes `qdbd check --strict` pastes in unchanged.
|
|
192
|
+
|
|
193
|
+
## FAQ
|
|
194
|
+
|
|
195
|
+
**Do I need a QuickDBD account?**
|
|
196
|
+
No. qdbd only borrows the text syntax.
|
|
197
|
+
|
|
198
|
+
**Does qdbd connect to my database?**
|
|
199
|
+
No. It reads `.txt` schema files or a dbt `manifest.json`. Nothing connects to a warehouse.
|
|
200
|
+
|
|
201
|
+
**Does my schema leave my machine?**
|
|
202
|
+
Only if you run `qdbd share`, which uploads the page to a GitHub gist in your account (secret by default). `qdbd serve` loads its code editor from a CDN; the built pages load nothing.
|
|
203
|
+
|
|
204
|
+
**How big can a diagram get?**
|
|
205
|
+
The demos go up to 200 tables. Search, selectors, regions and collapsed views keep large diagrams workable; `--select` builds a page with just the part you need.
|
|
206
|
+
|
|
207
|
+
**Can I edit the diagram by hand?**
|
|
208
|
+
You edit the text; the diagram is generated from it. Table positions are the one thing you arrange yourself, by dragging in `qdbd serve`.
|
|
209
|
+
|
|
210
|
+
## Learn more
|
|
211
|
+
|
|
212
|
+
- [Install](https://qdbd.dev/install/) and [Quick Start](https://qdbd.dev/getting-started/)
|
|
213
|
+
- [Schema Syntax](https://qdbd.dev/syntax/), [many files](https://qdbd.dev/files/), [table positions](https://qdbd.dev/layout/), [tags and colours](https://qdbd.dev/tags/)
|
|
214
|
+
- [Reading the Diagram](https://qdbd.dev/reading-the-diagram/), [selectors](https://qdbd.dev/selectors/), [exports](https://qdbd.dev/exports/), [sharing a link](https://qdbd.dev/sharing/)
|
|
215
|
+
- [dbt Projects](https://qdbd.dev/dbt/), with a [jaffle_shop walkthrough](https://qdbd.dev/example/)
|
|
216
|
+
- [Schema Diffs](https://qdbd.dev/diffs/), the [GitHub Action](https://qdbd.dev/github-action/) and the [CLI reference](https://qdbd.dev/cli/)
|
|
217
|
+
- [Development](https://qdbd.dev/development/): working on qdbd itself, releasing, and adding a demo
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
Apache-2.0. Bundled third-party files (ELK, Inter) and the sources of the demo schemas are listed in [NOTICE](https://github.com/MarkPhamm/quickdbd-cli/blob/main/NOTICE).
|
|
@@ -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.12"
|
|
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"
|
|
@@ -37,7 +37,7 @@ Homepage = "https://github.com/MarkPhamm/quickdbd-cli"
|
|
|
37
37
|
packages = ["src/quickdbd_cli"]
|
|
38
38
|
|
|
39
39
|
[tool.hatch.build.targets.sdist]
|
|
40
|
-
include = ["src", "tests", "examples", "scripts", "README.md", "LICENSE", "NOTICE"]
|
|
40
|
+
include = ["src", "tests", "examples", "scripts", "/README.md", "/LICENSE", "/NOTICE"]
|
|
41
41
|
|
|
42
42
|
[tool.ruff]
|
|
43
43
|
line-length = 120
|