dbterd


Namedbterd JSON
Version 1.18.0 PyPI version JSON
download
home_pagehttps://github.com/datnguye/dbterd
SummaryGenerate the ERD-as-a-code from dbt artifacts
upload_time2024-09-03 07:39:47
maintainerNone
docs_urlNone
authorDat Nguyen
requires_python<4.0,>=3.9
licenseMIT
keywords flake8 markdown lint
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dbterd

Generate the ERD-as-a-code ([DBML](https://dbdiagram.io/d), [Mermaid](https://mermaid-js.github.io/mermaid-live-editor/), [PlantUML](https://plantuml.com/ie-diagram), [GraphViz](https://graphviz.org/), [D2](https://d2lang.com/), [DrawDB](https://drawdb.vercel.app/)) from dbt artifact files (`dbt Core`) or from dbt metadata (`dbt Cloud`)

Entity Relationships are configurably detected by ([docs](https://dbterd.datnguyen.de/latest/nav/guide/cli-references.html#dbterd-run-algo-a)):

- [Test Relationships](https://docs.getdbt.com/reference/resource-properties/data-tests#relationships) (default)
- [Semantic Entities](https://docs.getdbt.com/docs/build/entities) (use `-a` option)

[![PyPI version](https://badge.fury.io/py/dbterd.svg)](https://pypi.org/project/dbterd/)
![python-cli](https://img.shields.io/badge/CLI-Python-FFCE3E?labelColor=14354C&logo=python&logoColor=white)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![python](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
[![codecov](https://codecov.io/gh/datnguye/dbterd/branch/main/graph/badge.svg?token=N7DMQBLH4P)](https://codecov.io/gh/datnguye/dbterd)

```bash
pip install dbterd --upgrade
```

Verify installation:

```bash
dbterd --version
```

> [!TIP]
> For `dbt-core` Users, it's highly recommended to upgrade `dbt-artifacts-parser` to the latest version in order to support the newer `dbt-core` version which would cause to have the [new manifest / catalog json schema](https://schemas.getdbt.com/):</br>
> πŸ‘‰ `pip install dbt-artifacts-parser --upgrade`

## Quick examine with existing samples

- Play with CLIs:

  <details>
    <summary>Click me</summary>

    ```bash
    # select all models in dbt_resto
    dbterd run -ad samples/dbtresto
    # select all models in dbt_resto, Select multiple dbt resources
    dbterd run -ad samples/dbtresto -rt model -rt source
    # select only models in dbt_resto excluding staging
    dbterd run -ad samples/dbtresto -s model.dbt_resto -ns model.dbt_resto.staging
    # select only models in schema name mart excluding staging
    dbterd run -ad samples/dbtresto -s schema:mart -ns model.dbt_resto.staging
    # select only models in schema full name dbt.mart excluding staging
    dbterd run -ad samples/dbtresto -s schema:dbt.mart -ns model.dbt_resto.staging

    # other samples
    dbterd run -ad samples/fivetranlog
    dbterd run -ad samples/fivetranlog -rt model -rt source

    dbterd run -ad samples/facebookad
    dbterd run -ad samples/facebookad -rt model -rt source

    dbterd run -ad samples/shopify -s wildcard:*shopify.shopify__*
    dbterd run -ad samples/shopify -rt model -rt source

    dbterd run -ad samples/dbt-constraints -a "test_relationship:(name:foreign_key|c_from:fk_column_name|c_to:pk_column_name)"

    # your own sample without committing to repo
    dbterd run -ad samples/local -rt model -rt source
    ```

  </details>

- Play with Python API (whole ERD):

    ```python
    from dbterd.api import DbtErd

    erd = DbtErd().get_erd()
    print("erd (dbml):", erd)

    erd = DbtErd(target="mermaid").get_erd()
    print("erd (mermaid):", erd)
    ```

- Play with Python API (1 model's ERD):

    ```python
    from dbterd.api import DbtErd

    dim_prize_erd = DbtErd(target="mermaid").get_model_erd(
        node_unique_id="model.dbt_resto.dim_prize"
    )
    print("erd of dim_prize (mermaid):", dim_prize_erd)
    ```

    Here is the output:

    ```mermaid
    erDiagram
      "MODEL.DBT_RESTO.DIM_PRIZE" {
        varchar prize_key
        nvarchar prize_name
        int prize_order
      }
      "MODEL.DBT_RESTO.FACT_RESULT" {
        varchar fact_result_key
        varchar box_key
        varchar prize_key
        date date_key
        int no_of_won
        float prize_value
        float prize_paid
        int is_prize_taken
      }
      "MODEL.DBT_RESTO.FACT_RESULT" }|--|| "MODEL.DBT_RESTO.DIM_PRIZE": prize_key
    ```

</details>

πŸƒCheck out the [Quick Demo](https://dbterd.datnguyen.de/latest/nav/guide/targets/generate-dbml.html) with DBML!

## Contributing ✨

If you've ever wanted to contribute to this tool, and a great cause, now is your chance!

See the contributing docs [CONTRIBUTING](https://dbterd.datnguyen.de/latest/nav/development/contributing-guide.html) for more information.

If you've found this tool to be very helpful, please consider giving the repository a star, sharing it on social media, or even writing a blog post about it πŸ’Œ

[![dbterd stars](https://img.shields.io/github/stars/datnguye/dbterd.svg?logo=github&style=for-the-badge&label=Star%20this%20repo)](https://github.com/datnguye/dbterd)
[![buy me a coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?logo=buy-me-a-coffee&logoColor=white&labelColor=ff813f&style=for-the-badge)](https://www.buymeacoffee.com/datnguye)

Finally, super thanks to our *Contributors*:

<a href="https://github.com/datnguye/dbterd/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=datnguye/dbterd" />
</a>

</br>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/datnguye/dbterd",
    "name": "dbterd",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "flake8, markdown, lint",
    "author": "Dat Nguyen",
    "author_email": "datnguyen.it09@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a2/0c/d1e2e3768c4d642761fef8cfdf0a700371c08546569b7c587cd247dacb81/dbterd-1.18.0.tar.gz",
    "platform": null,
    "description": "# dbterd\n\nGenerate the ERD-as-a-code ([DBML](https://dbdiagram.io/d), [Mermaid](https://mermaid-js.github.io/mermaid-live-editor/), [PlantUML](https://plantuml.com/ie-diagram), [GraphViz](https://graphviz.org/), [D2](https://d2lang.com/), [DrawDB](https://drawdb.vercel.app/)) from dbt artifact files (`dbt Core`) or from dbt metadata (`dbt Cloud`)\n\nEntity Relationships are configurably detected by ([docs](https://dbterd.datnguyen.de/latest/nav/guide/cli-references.html#dbterd-run-algo-a)):\n\n- [Test Relationships](https://docs.getdbt.com/reference/resource-properties/data-tests#relationships) (default)\n- [Semantic Entities](https://docs.getdbt.com/docs/build/entities) (use `-a` option)\n\n[![PyPI version](https://badge.fury.io/py/dbterd.svg)](https://pypi.org/project/dbterd/)\n![python-cli](https://img.shields.io/badge/CLI-Python-FFCE3E?labelColor=14354C&logo=python&logoColor=white)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![python](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)\n[![codecov](https://codecov.io/gh/datnguye/dbterd/branch/main/graph/badge.svg?token=N7DMQBLH4P)](https://codecov.io/gh/datnguye/dbterd)\n\n```bash\npip install dbterd --upgrade\n```\n\nVerify installation:\n\n```bash\ndbterd --version\n```\n\n> [!TIP]\n> For `dbt-core` Users, it's highly recommended to upgrade `dbt-artifacts-parser` to the latest version in order to support the newer `dbt-core` version which would cause to have the [new manifest / catalog json schema](https://schemas.getdbt.com/):</br>\n> \ud83d\udc49 `pip install dbt-artifacts-parser --upgrade`\n\n## Quick examine with existing samples\n\n- Play with CLIs:\n\n  <details>\n    <summary>Click me</summary>\n\n    ```bash\n    # select all models in dbt_resto\n    dbterd run -ad samples/dbtresto\n    # select all models in dbt_resto, Select multiple dbt resources\n    dbterd run -ad samples/dbtresto -rt model -rt source\n    # select only models in dbt_resto excluding staging\n    dbterd run -ad samples/dbtresto -s model.dbt_resto -ns model.dbt_resto.staging\n    # select only models in schema name mart excluding staging\n    dbterd run -ad samples/dbtresto -s schema:mart -ns model.dbt_resto.staging\n    # select only models in schema full name dbt.mart excluding staging\n    dbterd run -ad samples/dbtresto -s schema:dbt.mart -ns model.dbt_resto.staging\n\n    # other samples\n    dbterd run -ad samples/fivetranlog\n    dbterd run -ad samples/fivetranlog -rt model -rt source\n\n    dbterd run -ad samples/facebookad\n    dbterd run -ad samples/facebookad -rt model -rt source\n\n    dbterd run -ad samples/shopify -s wildcard:*shopify.shopify__*\n    dbterd run -ad samples/shopify -rt model -rt source\n\n    dbterd run -ad samples/dbt-constraints -a \"test_relationship:(name:foreign_key|c_from:fk_column_name|c_to:pk_column_name)\"\n\n    # your own sample without committing to repo\n    dbterd run -ad samples/local -rt model -rt source\n    ```\n\n  </details>\n\n- Play with Python API (whole ERD):\n\n    ```python\n    from dbterd.api import DbtErd\n\n    erd = DbtErd().get_erd()\n    print(\"erd (dbml):\", erd)\n\n    erd = DbtErd(target=\"mermaid\").get_erd()\n    print(\"erd (mermaid):\", erd)\n    ```\n\n- Play with Python API (1 model's ERD):\n\n    ```python\n    from dbterd.api import DbtErd\n\n    dim_prize_erd = DbtErd(target=\"mermaid\").get_model_erd(\n        node_unique_id=\"model.dbt_resto.dim_prize\"\n    )\n    print(\"erd of dim_prize (mermaid):\", dim_prize_erd)\n    ```\n\n    Here is the output:\n\n    ```mermaid\n    erDiagram\n      \"MODEL.DBT_RESTO.DIM_PRIZE\" {\n        varchar prize_key\n        nvarchar prize_name\n        int prize_order\n      }\n      \"MODEL.DBT_RESTO.FACT_RESULT\" {\n        varchar fact_result_key\n        varchar box_key\n        varchar prize_key\n        date date_key\n        int no_of_won\n        float prize_value\n        float prize_paid\n        int is_prize_taken\n      }\n      \"MODEL.DBT_RESTO.FACT_RESULT\" }|--|| \"MODEL.DBT_RESTO.DIM_PRIZE\": prize_key\n    ```\n\n</details>\n\n\ud83c\udfc3Check out the [Quick Demo](https://dbterd.datnguyen.de/latest/nav/guide/targets/generate-dbml.html) with DBML!\n\n## Contributing \u2728\n\nIf you've ever wanted to contribute to this tool, and a great cause, now is your chance!\n\nSee the contributing docs [CONTRIBUTING](https://dbterd.datnguyen.de/latest/nav/development/contributing-guide.html) for more information.\n\nIf you've found this tool to be very helpful, please consider giving the repository a star, sharing it on social media, or even writing a blog post about it \ud83d\udc8c\n\n[![dbterd stars](https://img.shields.io/github/stars/datnguye/dbterd.svg?logo=github&style=for-the-badge&label=Star%20this%20repo)](https://github.com/datnguye/dbterd)\n[![buy me a coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?logo=buy-me-a-coffee&logoColor=white&labelColor=ff813f&style=for-the-badge)](https://www.buymeacoffee.com/datnguye)\n\nFinally, super thanks to our *Contributors*:\n\n<a href=\"https://github.com/datnguye/dbterd/graphs/contributors\">\n  <img src=\"https://contrib.rocks/image?repo=datnguye/dbterd\" />\n</a>\n\n</br>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate the ERD-as-a-code from dbt artifacts",
    "version": "1.18.0",
    "project_urls": {
        "Homepage": "https://github.com/datnguye/dbterd",
        "Repository": "https://github.com/datnguye/dbterd"
    },
    "split_keywords": [
        "flake8",
        " markdown",
        " lint"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d913a313d5ff1fc9597a530b600cfd808a8eae0524071c6b7fb0a5caa6833353",
                "md5": "9dc582bd47d042fafa53ba5649436102",
                "sha256": "676371862f9edc45458c3bfcfe07ae1652c8bf99490d474a92d19dd153ddb9f7"
            },
            "downloads": -1,
            "filename": "dbterd-1.18.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9dc582bd47d042fafa53ba5649436102",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 47889,
            "upload_time": "2024-09-03T07:39:45",
            "upload_time_iso_8601": "2024-09-03T07:39:45.602635Z",
            "url": "https://files.pythonhosted.org/packages/d9/13/a313d5ff1fc9597a530b600cfd808a8eae0524071c6b7fb0a5caa6833353/dbterd-1.18.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a20cd1e2e3768c4d642761fef8cfdf0a700371c08546569b7c587cd247dacb81",
                "md5": "35dbba2e7cc774acafaf8015df7fd0a2",
                "sha256": "2ad38864c7fdf1147ed4014fb98c0988c8d51e87322d4a1fefb8327af9d297dc"
            },
            "downloads": -1,
            "filename": "dbterd-1.18.0.tar.gz",
            "has_sig": false,
            "md5_digest": "35dbba2e7cc774acafaf8015df7fd0a2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 33371,
            "upload_time": "2024-09-03T07:39:47",
            "upload_time_iso_8601": "2024-09-03T07:39:47.706889Z",
            "url": "https://files.pythonhosted.org/packages/a2/0c/d1e2e3768c4d642761fef8cfdf0a700371c08546569b7c587cd247dacb81/dbterd-1.18.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-03 07:39:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datnguye",
    "github_project": "dbterd",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dbterd"
}
        
Elapsed time: 0.60136s