You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix inserted rows count to avoid returning 0 when the count is not returned by the backend
* Add zooming capability in `xml2db serve`
* Write documentation for CLI usage
* Several documentation editing
---------
Co-authored-by: Claude <noreply@anthropic.com>
Launch an interactive schema explorer in the browser.
87
+
88
+
```
89
+
xml2db serve XSD_FILE [options]
90
+
```
91
+
92
+
The explorer shows four tabs: ERD, target tree, source tree, and DDL. The left panel is a YAML config editor with autocomplete for table names, field names, and all config options. Edits trigger an automatic rebuild. The **Save** button writes the config back to disk.
93
+
94
+
**Positional arguments:**
95
+
96
+
| Argument | Description |
97
+
|---|---|
98
+
|`XSD_FILE`| Path to the XSD schema file |
99
+
100
+
**Options:**
101
+
102
+
| Option | Description |
103
+
|---|---|
104
+
|`--config FILE`, `-c FILE`| YAML model config file to load on startup; Save writes it back to this path (default: `model_config.yml`) |
105
+
|`--db-type BACKEND`| Database backend for the DDL tab (`postgresql`, `mssql`, `mysql`, ...) |
106
+
|`--no-browser`| Do not open the browser automatically |
107
+
|`--port PORT`, `-p PORT`| HTTP port (default: `8765`) |
108
+
|`--short-name NAME`| Data model short name (default: `DocumentRoot`) |
The following options can be passed as top-level keys of the model configuration `dict`:
82
82
83
+
* `as_columnstore` (`bool`): for MS SQL Server, create clustered columnstore indexes on all tables. This can be also set up at
84
+
the table level for each table. However, for `n-n` relationships tables, this option is the only way to configure the
85
+
clustered columnstore indexes. The default value is `False` (disabled).
83
86
* `document_tree_hook` (`Callable`): sets a hook function which can modify the data extracted from the XML. It gives direct
84
87
access to the underlying tree data structure just before it is extracted to be loaded to the database. This can be used,
85
88
for instance, to prune or modify some parts of the document tree before loading it into the database. The document tree
@@ -89,24 +92,21 @@ the declarative [`"transform": "skip"`](#skipping-fields) option is simpler.
89
92
similar with `document_tree_hook`, but it is called as soon as a node is completed, not waiting for the entire parsing to
90
93
finish. It is especially useful if you intend to filter out some nodes and reduce memory footprint while parsing. For
91
94
straightforward field exclusion, see [`"transform": "skip"`](#skipping-fields).
92
-
* `row_numbers` (`bool`): adds `xml2db_row_number` columns either to `n-n` relationships tables, or directly to data tables when
93
-
deduplication of rows is opted out. This allows recording the original order of elements in the source XML, which is not
94
-
always respected otherwise. It was implemented primarily for round-trip tests, but could serve other purposes. The
95
-
default value is `False` (disabled).
96
-
* `as_columnstore` (`bool`): for MS SQL Server, create clustered columnstore indexes on all tables. This can be also set up at
97
-
the table level for each table. However, for `n-n` relationships tables, this option is the only way to configure the
98
-
clustered columnstore indexes. The default value is `False` (disabled).
99
95
* `metadata_columns` (`list`): a list of extra columns that you want to add to the root table of your model. This is
100
96
useful for instance to add the name of the file which has been parsed, or a timestamp, etc. Columns should be specified
101
97
as dicts, the only required keys are `name` and `type` (a SQLAlchemy type object); other keys will be passed directly
102
98
as keyword arguments to `sqlalchemy.Column`. Actual values need to be passed to
103
99
[`DataModel.parse_xml`](api/data_model.md#xml2db.model.DataModel.parse_xml) for each
104
100
parsed documents, as a `dict`, using the `metadata` argument.
105
-
* `transform` (`false` or `"auto"`): set to `false` to disable all automatic field transformations globally: no joining of multi-value columns, no elevation of child tables, no collapsing of choice groups. The default `"auto"` applies all of these where applicable. Per-field `transform` and per-table `choice_transform` still override the global setting.
106
101
* `record_hash_column_name`: the column name to use to store records hash data (defaults to `xml2db_record_hash`).
107
102
* `record_hash_constructor`: a function used to build a hash, with a signature similar to `hashlib` constructor
108
103
functions (defaults to `hashlib.sha1`).
109
104
* `record_hash_size`: the byte size of the record hash (defaults to 20, which is the size of a `sha-1` hash).
105
+
* `row_numbers` (`bool`): adds `xml2db_row_number` columns either to `n-n` relationships tables, or directly to data tables when
106
+
deduplication of rows is opted out. This allows recording the original order of elements in the source XML, which is not
107
+
always respected otherwise. It was implemented primarily for round-trip tests, but could serve other purposes. The
108
+
default value is `False` (disabled).
109
+
* `transform` (`false` or `"auto"`): set to `false` to disable all automatic field transformations globally: no joining of multi-value columns, no elevation of child tables, no collapsing of choice groups. The default `"auto"` applies all of these where applicable. Per-field `transform` and per-table `choice_transform` still override the global setting.
Copy file name to clipboardExpand all lines: docs/getting_started.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,8 @@ This opens a browser with four tabs:
39
39
-**Source tree**: a text tree of the raw XSD structure before simplification
40
40
-**DDL**: `CREATE TABLE` statements for the target schema
41
41
42
-
The left panel is a YAML config editor with autocomplete for table names, field names, and all config options. Edit the config and the diagram updates automatically (with a short debounce). When the config looks right, click **Save** to write it to a file (default: `model_config.yml`).
42
+
The left panel is a YAML config editor with autocomplete for table names, field names, and all config options. Edit the config and the diagram updates automatically.
43
+
When the config looks right, click **Save** to write it to a file (default: `model_config.yml`).
43
44
44
45
You can also render these representations directly to stdout or a file without the browser:
45
46
@@ -54,7 +55,7 @@ See [Configuring your data model](configuring.md) for a full description of the
54
55
55
56
## Importing XML files
56
57
57
-
Once the data model looks right, import an XML file into the database:
58
+
Once you are happy with the data model, import an XML file into the database (config is optional):
58
59
59
60
```bash
60
61
xml2db import file.xml schema.xsd \
@@ -96,7 +97,7 @@ with open("data_model_erd.md", "w") as f:
96
97
f.write(data_model.get_entity_rel_diagram())
97
98
```
98
99
99
-
The diagram uses [Mermaid](https://mermaid.js.org/syntax/entityRelationshipDiagram.html). PyCharm and GitHub both render Mermaid natively.
100
+
The diagram uses [Mermaid](https://mermaid.js.org/syntax/entityRelationshipDiagram.html). Your IDE should be able to render Mermaid preview.
100
101
101
102
```py title="Write source and target trees to files" linenums="1"
0 commit comments