erdscope 0.5.0__tar.gz → 0.7.0__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.
Files changed (32) hide show
  1. erdscope-0.7.0/PKG-INFO +235 -0
  2. erdscope-0.7.0/README.md +201 -0
  3. {erdscope-0.5.0 → erdscope-0.7.0}/erd.py +1998 -83
  4. erdscope-0.7.0/erdscope.egg-info/PKG-INFO +235 -0
  5. {erdscope-0.5.0 → erdscope-0.7.0}/erdscope.egg-info/SOURCES.txt +7 -0
  6. {erdscope-0.5.0 → erdscope-0.7.0}/pyproject.toml +1 -1
  7. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_config_validation.py +482 -2
  8. erdscope-0.7.0/tests/test_diff.py +696 -0
  9. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_e2e.py +521 -0
  10. erdscope-0.7.0/tests/test_emit_config.py +859 -0
  11. erdscope-0.7.0/tests/test_emit_json.py +536 -0
  12. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_erd.py +116 -0
  13. erdscope-0.7.0/tests/test_golden_format1.py +308 -0
  14. erdscope-0.7.0/tests/test_groups.py +325 -0
  15. erdscope-0.7.0/tests/test_notes.py +556 -0
  16. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_pipeline.py +73 -8
  17. erdscope-0.7.0/tests/test_provider_contract.py +221 -0
  18. erdscope-0.5.0/PKG-INFO +0 -459
  19. erdscope-0.5.0/README.md +0 -425
  20. erdscope-0.5.0/erdscope.egg-info/PKG-INFO +0 -459
  21. {erdscope-0.5.0 → erdscope-0.7.0}/LICENSE +0 -0
  22. {erdscope-0.5.0 → erdscope-0.7.0}/erdscope.egg-info/dependency_links.txt +0 -0
  23. {erdscope-0.5.0 → erdscope-0.7.0}/erdscope.egg-info/entry_points.txt +0 -0
  24. {erdscope-0.5.0 → erdscope-0.7.0}/erdscope.egg-info/requires.txt +0 -0
  25. {erdscope-0.5.0 → erdscope-0.7.0}/erdscope.egg-info/top_level.txt +0 -0
  26. {erdscope-0.5.0 → erdscope-0.7.0}/setup.cfg +0 -0
  27. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_build.py +0 -0
  28. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_characterization.py +0 -0
  29. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_db_integration.py +0 -0
  30. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_demo.py +0 -0
  31. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_merge_ir.py +0 -0
  32. {erdscope-0.5.0 → erdscope-0.7.0}/tests/test_rails_schema.py +0 -0
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: erdscope
3
+ Version: 0.7.0
4
+ Summary: Interactive, self-contained ER-diagram HTML and Excel table definitions from a MySQL, PostgreSQL, or SQLite database and/or application code (Rails / Prisma / Django) — single file, zero required dependencies
5
+ Author: tas6
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/orapli/erdscope
8
+ Project-URL: Documentation, https://orapli.github.io/erdscope/manual.html
9
+ Project-URL: Live demo, https://orapli.github.io/erdscope/
10
+ Project-URL: Repository, https://github.com/orapli/erdscope
11
+ Project-URL: Issues, https://github.com/orapli/erdscope/issues
12
+ Keywords: erd,er-diagram,database,schema,mysql,postgresql,postgres,sqlite,rails,prisma,django,documentation
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Database
18
+ Classifier: Topic :: Documentation
19
+ Classifier: Topic :: Software Development :: Documentation
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Provides-Extra: mysql
24
+ Requires-Dist: PyMySQL; extra == "mysql"
25
+ Provides-Extra: postgres
26
+ Requires-Dist: psycopg[binary]; extra == "postgres"
27
+ Provides-Extra: yaml
28
+ Requires-Dist: PyYAML; extra == "yaml"
29
+ Provides-Extra: all
30
+ Requires-Dist: PyMySQL; extra == "all"
31
+ Requires-Dist: psycopg[binary]; extra == "all"
32
+ Requires-Dist: PyYAML; extra == "all"
33
+ Dynamic: license-file
34
+
35
+ <div align="center">
36
+ <img src="docs/img/erdscope-banner.svg" alt="erdscope — explore the schema you have" width="100%">
37
+
38
+ **Database, application code, or config — turn whatever you have into one explorable schema.**
39
+
40
+ [![CI](https://github.com/orapli/erdscope/actions/workflows/ci.yml/badge.svg)](https://github.com/orapli/erdscope/actions/workflows/ci.yml)
41
+ [![PyPI](https://img.shields.io/pypi/v/erdscope)](https://pypi.org/project/erdscope/)
42
+ [![Python](https://img.shields.io/badge/Python-3.9%2B-3776AB)](https://pypi.org/project/erdscope/)
43
+ [![License](https://img.shields.io/badge/license-MIT-14B8A6)](LICENSE)
44
+
45
+ [Live demo](https://orapli.github.io/erdscope/) · [User manual](https://orapli.github.io/erdscope/manual.html) · [日本語マニュアル](https://orapli.github.io/erdscope/manual.ja.html)
46
+ </div>
47
+
48
+ erdscope generates a **self-contained, interactive ER diagram** and, when you want it,
49
+ an **Excel table-definition workbook**. Start with a database, model code, a config file,
50
+ or any combination of them. The result is one portable HTML file you can explore, share,
51
+ and keep with your project.
52
+
53
+ ```bash
54
+ pip install erdscope
55
+ erdscope demo
56
+ ```
57
+
58
+ That is the whole quickstart. A sample shop diagram opens in your browser—no database,
59
+ account, or project setup required.
60
+
61
+ [![Interactive diagram generated by erdscope](docs/screenshot.png)](https://orapli.github.io/erdscope/)
62
+
63
+ ## Bring whatever schema you have
64
+
65
+ <div align="center">
66
+ <img src="docs/img/input-flow.svg" alt="Database, application code, and config merge into an interactive ER diagram and Excel workbook" width="880">
67
+ </div>
68
+
69
+ | Start from | What erdscope reads | Good for |
70
+ |---|---|---|
71
+ | **A database** | MySQL, PostgreSQL, or SQLite catalogs | Exploring the schema that is actually deployed |
72
+ | **Application code** | Rails, Prisma, or Django projects | Reviewing a project without database access |
73
+ | **Config** | JSON or YAML source declarations, tables, relations, notes, and groups | Reusing settings, designing a schema, or adding documentation |
74
+
75
+ Use just one source, or combine them. Physical database facts, application-level
76
+ associations, and your explicit documentation are merged into one consistent view.
77
+
78
+ The examples below use CLI arguments when that makes the input obvious. For repeatable
79
+ usage, put the same settings and model sources in `.erdscope.json`, `.erdscope.yml`, or
80
+ another file selected with `--config`. A config can also define a complete schema by
81
+ itself. Explicit CLI arguments override the corresponding config values.
82
+
83
+ ## Pick your starting point
84
+
85
+ ### Explore a live database
86
+
87
+ ```bash
88
+ erdscope postgres://readonly@127.0.0.1:5432/myapp -o schema.html
89
+ ```
90
+
91
+ MySQL uses the same shape. SQLite needs no driver and works with Python's standard library:
92
+
93
+ ```bash
94
+ erdscope sqlite:///path/to/app.db -o schema.html
95
+ ```
96
+
97
+ ### Review application models without a database
98
+
99
+ ```bash
100
+ # Rails, Prisma, or Django project — auto-detected
101
+ erdscope --models ./my-app -o schema.html
102
+ ```
103
+
104
+ ### Sketch or document a schema from config alone
105
+
106
+ ```bash
107
+ erdscope --config examples/schema-only.json -o schema.html
108
+ ```
109
+
110
+ [`examples/schema-only.json`](examples/schema-only.json) is a complete, zero-database
111
+ example with tables, relations, notes, and a domain group. Config can also patch or remove
112
+ items supplied by another source. See the [config guide](https://orapli.github.io/erdscope/manual.html#config-file).
113
+
114
+ ### Combine database facts, application context, and documentation
115
+
116
+ ```bash
117
+ erdscope mysql://readonly@127.0.0.1:3306/myapp \
118
+ --config .erdscope.yml \
119
+ -o schema.html
120
+ ```
121
+
122
+ ```yaml
123
+ # .erdscope.yml
124
+ models:
125
+ - ./app/models
126
+ groups:
127
+ - { id: sales, title: Sales, tables: [orders, order_items] }
128
+ notes:
129
+ - id: order-retention
130
+ target: { type: table, table: orders }
131
+ text: Orders are retained for seven years after account closure.
132
+ ```
133
+
134
+ This is where the layered input model shines: use the database for columns and real
135
+ foreign keys, code for associations such as polymorphic or through relations, and config
136
+ for corrections, domain groups, operational notes, and ADR links.
137
+
138
+ ### Hand off both a diagram and table definitions
139
+
140
+ ```bash
141
+ erdscope sqlite:///path/to/app.db \
142
+ -o schema.html \
143
+ --excel table-definitions.xlsx
144
+ ```
145
+
146
+ The HTML is self-contained and the workbook can be styled with an Excel template—useful
147
+ for reviews, audits, onboarding, and documentation deliverables.
148
+
149
+ ## What you can do in the viewer
150
+
151
+ - Search tables, columns, comments, and attached notes.
152
+ - Focus on dependencies or dependents and control traversal depth.
153
+ - Hide tables, rearrange the layout, and move domain groups together.
154
+ - Inspect DB FKs, schema FKs, declared associations, and inferred relations.
155
+ - Save named views and share a link to the current view.
156
+ - Export the current canvas as PNG or SVG, or print it cleanly.
157
+ - Switch to dark mode; everything runs locally in the generated HTML.
158
+
159
+ Try these interactions in the **[live demo](https://orapli.github.io/erdscope/)**, or use
160
+ the illustrated **[viewer guide](https://orapli.github.io/erdscope/manual.html#viewer-guide)**.
161
+
162
+ ## Installation
163
+
164
+ ```bash
165
+ pip install erdscope
166
+ ```
167
+
168
+ The core CLI, SQLite reader, HTML generator, and Excel writer use only the Python standard
169
+ library. Install an optional driver when you want a direct server connection:
170
+
171
+ ```bash
172
+ pip install 'erdscope[mysql]' # PyMySQL
173
+ pip install 'erdscope[postgres]' # psycopg
174
+ pip install 'erdscope[yaml]' # PyYAML for .yml/.yaml config
175
+ pip install 'erdscope[all]'
176
+ ```
177
+
178
+ Prefer a single file? Download [`erd.py`](erd.py) and run it with Python 3.9+:
179
+
180
+ ```bash
181
+ python3 erd.py demo
182
+ ```
183
+
184
+ ## Config and CLI overrides
185
+
186
+ Config is the convenient home for recurring inputs and settings. It is auto-discovered
187
+ as `.erdscope.json`, `.erdscope.yml`, or `.erdscope.yaml` in the current directory, or
188
+ you can select a file with `--config`. When the same setting is supplied both ways, the
189
+ explicit CLI argument wins.
190
+
191
+ | Option | Purpose |
192
+ |---|---|
193
+ | `--config PATH` | Load model sources, defaults, schema definitions or patches, notes, and groups |
194
+ | `--models PATH` | Override config `models` with Rails, Prisma, or Django input; repeatable |
195
+ | `--excel FILE.xlsx` | Also generate a table-definition workbook |
196
+ | `--emit-json FILE.json` | Also write a canonical JSON schema snapshot with a content fingerprint (`-` for stdout) |
197
+ | `--emit-config FILE.yml\|.json` | Also write the schema as a config-authoring file, re-importable via `--config` (`-` for stdout, always JSON) |
198
+ | `--diff SNAPSHOT.json` | Compare this run against a saved `--emit-json` snapshot and exit 0/1/2 instead of generating output (CI drift gate) |
199
+ | `--only 'user*,order*'` | Generate only matching tables |
200
+ | `--exclude '*_logs'` | Leave matching tables out |
201
+ | `--infer-fk` | Add clearly marked relation guesses from `*_id` columns |
202
+ | `--no-open` | Do not open the browser after `demo` |
203
+
204
+ For every option and config key, see the **[CLI and config reference](https://orapli.github.io/erdscope/manual.html#cli-reference)**.
205
+
206
+ ## Supported inputs
207
+
208
+ erdscope is tested against MySQL 8.4, PostgreSQL 16, CPython's bundled SQLite, Rails
209
+ 7.x/8.x projects, Prisma 5/6 schemas, and Django 4.2/5.x models. Details and parser
210
+ boundaries are listed in the
211
+ [compatibility guide](https://orapli.github.io/erdscope/manual.html#verified-versions).
212
+
213
+ ## Project resources
214
+
215
+ - **[Live demo](https://orapli.github.io/erdscope/)** — explore a generated shop schema.
216
+ - **[User manual](https://orapli.github.io/erdscope/manual.html)** — complete setup, viewer, config, export, and troubleshooting guide.
217
+ - **[Examples](examples/)** — ready-to-run SQLite and config-only inputs.
218
+ - **[Changelog](CHANGELOG.md)** — features and behavior by release.
219
+ - **[Issues](https://github.com/orapli/erdscope/issues)** — bug reports and feature requests.
220
+
221
+ ## Development
222
+
223
+ Source lives under `src/erdscope/`; the distributable `erd.py` is generated from it.
224
+
225
+ ```bash
226
+ python3 -m unittest discover -s tests -v
227
+ python3 tools/build_single_file.py --check
228
+ ```
229
+
230
+ See the [engineering quickstart](openwiki/quickstart.md) before changing providers,
231
+ merge behavior, the viewer, or generated artifacts.
232
+
233
+ ## License
234
+
235
+ [MIT](LICENSE)
@@ -0,0 +1,201 @@
1
+ <div align="center">
2
+ <img src="docs/img/erdscope-banner.svg" alt="erdscope — explore the schema you have" width="100%">
3
+
4
+ **Database, application code, or config — turn whatever you have into one explorable schema.**
5
+
6
+ [![CI](https://github.com/orapli/erdscope/actions/workflows/ci.yml/badge.svg)](https://github.com/orapli/erdscope/actions/workflows/ci.yml)
7
+ [![PyPI](https://img.shields.io/pypi/v/erdscope)](https://pypi.org/project/erdscope/)
8
+ [![Python](https://img.shields.io/badge/Python-3.9%2B-3776AB)](https://pypi.org/project/erdscope/)
9
+ [![License](https://img.shields.io/badge/license-MIT-14B8A6)](LICENSE)
10
+
11
+ [Live demo](https://orapli.github.io/erdscope/) · [User manual](https://orapli.github.io/erdscope/manual.html) · [日本語マニュアル](https://orapli.github.io/erdscope/manual.ja.html)
12
+ </div>
13
+
14
+ erdscope generates a **self-contained, interactive ER diagram** and, when you want it,
15
+ an **Excel table-definition workbook**. Start with a database, model code, a config file,
16
+ or any combination of them. The result is one portable HTML file you can explore, share,
17
+ and keep with your project.
18
+
19
+ ```bash
20
+ pip install erdscope
21
+ erdscope demo
22
+ ```
23
+
24
+ That is the whole quickstart. A sample shop diagram opens in your browser—no database,
25
+ account, or project setup required.
26
+
27
+ [![Interactive diagram generated by erdscope](docs/screenshot.png)](https://orapli.github.io/erdscope/)
28
+
29
+ ## Bring whatever schema you have
30
+
31
+ <div align="center">
32
+ <img src="docs/img/input-flow.svg" alt="Database, application code, and config merge into an interactive ER diagram and Excel workbook" width="880">
33
+ </div>
34
+
35
+ | Start from | What erdscope reads | Good for |
36
+ |---|---|---|
37
+ | **A database** | MySQL, PostgreSQL, or SQLite catalogs | Exploring the schema that is actually deployed |
38
+ | **Application code** | Rails, Prisma, or Django projects | Reviewing a project without database access |
39
+ | **Config** | JSON or YAML source declarations, tables, relations, notes, and groups | Reusing settings, designing a schema, or adding documentation |
40
+
41
+ Use just one source, or combine them. Physical database facts, application-level
42
+ associations, and your explicit documentation are merged into one consistent view.
43
+
44
+ The examples below use CLI arguments when that makes the input obvious. For repeatable
45
+ usage, put the same settings and model sources in `.erdscope.json`, `.erdscope.yml`, or
46
+ another file selected with `--config`. A config can also define a complete schema by
47
+ itself. Explicit CLI arguments override the corresponding config values.
48
+
49
+ ## Pick your starting point
50
+
51
+ ### Explore a live database
52
+
53
+ ```bash
54
+ erdscope postgres://readonly@127.0.0.1:5432/myapp -o schema.html
55
+ ```
56
+
57
+ MySQL uses the same shape. SQLite needs no driver and works with Python's standard library:
58
+
59
+ ```bash
60
+ erdscope sqlite:///path/to/app.db -o schema.html
61
+ ```
62
+
63
+ ### Review application models without a database
64
+
65
+ ```bash
66
+ # Rails, Prisma, or Django project — auto-detected
67
+ erdscope --models ./my-app -o schema.html
68
+ ```
69
+
70
+ ### Sketch or document a schema from config alone
71
+
72
+ ```bash
73
+ erdscope --config examples/schema-only.json -o schema.html
74
+ ```
75
+
76
+ [`examples/schema-only.json`](examples/schema-only.json) is a complete, zero-database
77
+ example with tables, relations, notes, and a domain group. Config can also patch or remove
78
+ items supplied by another source. See the [config guide](https://orapli.github.io/erdscope/manual.html#config-file).
79
+
80
+ ### Combine database facts, application context, and documentation
81
+
82
+ ```bash
83
+ erdscope mysql://readonly@127.0.0.1:3306/myapp \
84
+ --config .erdscope.yml \
85
+ -o schema.html
86
+ ```
87
+
88
+ ```yaml
89
+ # .erdscope.yml
90
+ models:
91
+ - ./app/models
92
+ groups:
93
+ - { id: sales, title: Sales, tables: [orders, order_items] }
94
+ notes:
95
+ - id: order-retention
96
+ target: { type: table, table: orders }
97
+ text: Orders are retained for seven years after account closure.
98
+ ```
99
+
100
+ This is where the layered input model shines: use the database for columns and real
101
+ foreign keys, code for associations such as polymorphic or through relations, and config
102
+ for corrections, domain groups, operational notes, and ADR links.
103
+
104
+ ### Hand off both a diagram and table definitions
105
+
106
+ ```bash
107
+ erdscope sqlite:///path/to/app.db \
108
+ -o schema.html \
109
+ --excel table-definitions.xlsx
110
+ ```
111
+
112
+ The HTML is self-contained and the workbook can be styled with an Excel template—useful
113
+ for reviews, audits, onboarding, and documentation deliverables.
114
+
115
+ ## What you can do in the viewer
116
+
117
+ - Search tables, columns, comments, and attached notes.
118
+ - Focus on dependencies or dependents and control traversal depth.
119
+ - Hide tables, rearrange the layout, and move domain groups together.
120
+ - Inspect DB FKs, schema FKs, declared associations, and inferred relations.
121
+ - Save named views and share a link to the current view.
122
+ - Export the current canvas as PNG or SVG, or print it cleanly.
123
+ - Switch to dark mode; everything runs locally in the generated HTML.
124
+
125
+ Try these interactions in the **[live demo](https://orapli.github.io/erdscope/)**, or use
126
+ the illustrated **[viewer guide](https://orapli.github.io/erdscope/manual.html#viewer-guide)**.
127
+
128
+ ## Installation
129
+
130
+ ```bash
131
+ pip install erdscope
132
+ ```
133
+
134
+ The core CLI, SQLite reader, HTML generator, and Excel writer use only the Python standard
135
+ library. Install an optional driver when you want a direct server connection:
136
+
137
+ ```bash
138
+ pip install 'erdscope[mysql]' # PyMySQL
139
+ pip install 'erdscope[postgres]' # psycopg
140
+ pip install 'erdscope[yaml]' # PyYAML for .yml/.yaml config
141
+ pip install 'erdscope[all]'
142
+ ```
143
+
144
+ Prefer a single file? Download [`erd.py`](erd.py) and run it with Python 3.9+:
145
+
146
+ ```bash
147
+ python3 erd.py demo
148
+ ```
149
+
150
+ ## Config and CLI overrides
151
+
152
+ Config is the convenient home for recurring inputs and settings. It is auto-discovered
153
+ as `.erdscope.json`, `.erdscope.yml`, or `.erdscope.yaml` in the current directory, or
154
+ you can select a file with `--config`. When the same setting is supplied both ways, the
155
+ explicit CLI argument wins.
156
+
157
+ | Option | Purpose |
158
+ |---|---|
159
+ | `--config PATH` | Load model sources, defaults, schema definitions or patches, notes, and groups |
160
+ | `--models PATH` | Override config `models` with Rails, Prisma, or Django input; repeatable |
161
+ | `--excel FILE.xlsx` | Also generate a table-definition workbook |
162
+ | `--emit-json FILE.json` | Also write a canonical JSON schema snapshot with a content fingerprint (`-` for stdout) |
163
+ | `--emit-config FILE.yml\|.json` | Also write the schema as a config-authoring file, re-importable via `--config` (`-` for stdout, always JSON) |
164
+ | `--diff SNAPSHOT.json` | Compare this run against a saved `--emit-json` snapshot and exit 0/1/2 instead of generating output (CI drift gate) |
165
+ | `--only 'user*,order*'` | Generate only matching tables |
166
+ | `--exclude '*_logs'` | Leave matching tables out |
167
+ | `--infer-fk` | Add clearly marked relation guesses from `*_id` columns |
168
+ | `--no-open` | Do not open the browser after `demo` |
169
+
170
+ For every option and config key, see the **[CLI and config reference](https://orapli.github.io/erdscope/manual.html#cli-reference)**.
171
+
172
+ ## Supported inputs
173
+
174
+ erdscope is tested against MySQL 8.4, PostgreSQL 16, CPython's bundled SQLite, Rails
175
+ 7.x/8.x projects, Prisma 5/6 schemas, and Django 4.2/5.x models. Details and parser
176
+ boundaries are listed in the
177
+ [compatibility guide](https://orapli.github.io/erdscope/manual.html#verified-versions).
178
+
179
+ ## Project resources
180
+
181
+ - **[Live demo](https://orapli.github.io/erdscope/)** — explore a generated shop schema.
182
+ - **[User manual](https://orapli.github.io/erdscope/manual.html)** — complete setup, viewer, config, export, and troubleshooting guide.
183
+ - **[Examples](examples/)** — ready-to-run SQLite and config-only inputs.
184
+ - **[Changelog](CHANGELOG.md)** — features and behavior by release.
185
+ - **[Issues](https://github.com/orapli/erdscope/issues)** — bug reports and feature requests.
186
+
187
+ ## Development
188
+
189
+ Source lives under `src/erdscope/`; the distributable `erd.py` is generated from it.
190
+
191
+ ```bash
192
+ python3 -m unittest discover -s tests -v
193
+ python3 tools/build_single_file.py --check
194
+ ```
195
+
196
+ See the [engineering quickstart](openwiki/quickstart.md) before changing providers,
197
+ merge behavior, the viewer, or generated artifacts.
198
+
199
+ ## License
200
+
201
+ [MIT](LICENSE)