A Python application that creates Entity Relationship Diagrams (ERDs) in dbt projects using the open-source dbml language and the dbdocs tool for visualization.
The app requires the following artifacts to create the dbml file:
manifest.jsoncatalog.json
It should be noted that the information about relationships comes from the dbt relationships test and therefore the tool only works if these tests are implemented.
- Clone this repository to a folder and run:
pip install src/
or install directly from git using the following command:
pip install -U git+https://github.com/ScalefreeCOM/dbt-dbml-erd#subdirectory=src
- Set up the dbdocs cli for diagram creation by following the instructions here
- Test erdbt with the following command:
erdbt test/manifest.json test/catalog.json test.dbml test True
To use this application in your project, run the erdbt command with the following parameters in order:
- Path to the dbt
manifest.json - Path to the dbt
catalog.json - Path to store the dbml file
- Name of the project on dbdocs.io
TrueorFalseif you want to visualize the dbml file on dbdocs.io- (optional) Name of your relationships test
Example:
erdbt my_project/manifest.json my_project/catalog.json my_project/erd.dbml my_project_erd True my_project_relationships
This command will generate an ERD file named erd.dbml in the my_project folder, using the manifest.json and catalog.json files also located in that folder. The ERD will be uploaded to dbdocs.io under the project name my_project_erd and using the relationships test named my_project_relationships.