Skip to main content
Version: 1.15.0 (latest)

dlt.helpers.dbml

schema_to_dbml

def schema_to_dbml(schema: TStoredSchema,
*,
allow_custom_dbml_properties: bool = False,
include_dlt_tables: bool = True,
include_internal_dlt_ref: bool = True,
include_parent_child_ref: bool = True,
include_root_child_ref: bool = True,
group_by_resource: bool = False) -> Database

View source on GitHub

Convert a dlt.Schema object to a PyDBML representation.

Arguments:

  • schema - dlt schema to convert
  • allow_custom_dbml_properties - If True, store all dlt metadata on DBML properties. This will cause rendering errors in most DBML frontends. If True, dlt to DBML all metadata is preserved. If False, the conversion loses some details to reconstruct the dlt schema.
  • include_dlt_tables - If True, include data tables and internal dlt tables. This will influence table references and groups produced.
  • include_internal_dlt_ref - If True, include references between tables _dlt_version, _dlt_loads and _dlt_pipeline_state
  • include_parent_child_ref - If True, include references from child._dlt_parent_id to parent._dlt_id
  • include_root_child_ref - If True, include references from child._dlt_root_id to root._dlt_id
  • group_by_resource - If True, group tables by resource.

Returns:

DBML schema

export_to_dbml

@overload
def export_to_dbml(schema: dlt.Schema, *, path: None = None) -> str

View source on GitHub

Convert dlt.Schema to DBML and return the string

export_to_dbml

@overload
def export_to_dbml(schema: dlt.Schema, *, path: Union[pathlib.Path,
str]) -> str

View source on GitHub

Convert dlt.Schema to DBML and write result to path at specified path

export_to_dbml

def export_to_dbml(schema: dlt.Schema,
*,
path: Optional[Union[pathlib.Path, str]] = None,
allow_custom_dbml_properties: bool = False,
include_dlt_tables: bool = True,
include_internal_dlt_ref: bool = True,
include_parent_child_ref: bool = True,
include_root_child_ref: bool = True,
group_by_resource: bool = False) -> str

View source on GitHub

Convert a dlt.Schema to a a DBML string and return its value.

Arguments:

  • schema - dlt schema to convert
  • path - If specified, write the DBML string to the file at the specified path.
  • allow_custom_dbml_properties - If True, store all dlt metadata on DBML properties. This will cause rendering errors in most DBML frontends. If True, dlt to DBML all metadata is preserved. If False, the conversion loses some details to reconstruct the dlt schema.
  • include_dlt_tables - If True, include data tables and internal dlt tables. This will influence table references and groups produced.
  • include_internal_dlt_ref - If True, include references between tables _dlt_version, _dlt_loads and _dlt_pipeline_state
  • include_parent_child_ref - If True, include references from child._dlt_parent_id to parent._dlt_id
  • include_root_child_ref - If True, include references from child._dlt_root_id to root._dlt_id
  • group_by_resource - If True, group tables by resource.

Returns:

DBML string

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.