Skip to main content

Snowflake DBML Generator

The Snowflake DBML Generator is an open-source tool that translates Snowflake database schemas into DBML (Database Markup Language), facilitating easy generation of ER diagrams and comprehensive documentation of database structures.

For data engineers, analysts, and ML engineers, it enables you to bootstrap a rich interactive DB diagram directly from Snowflake.

Demo Install and Usage

Quick Start

pip install snowflake-dbml-generator
snowflake-dbml --interactive

Examples

Using Snowflake's Sample Data Sets, here are demonstrations of generating DBML and visualizing it with dbdiagram.io:

1. Snowflake TPCH SF100 Dataset

TPCH SF100 Dataset Diagram

2. Snowflake TPCDS SF100TCL Dataset

TPCDS SF100TCL Dataset Diagram

Features

  • Automatic DBML Generation: Converts Snowflake schema definitions into DBML automatically.
  • Complex Schema Support: Manages complex relationships, including composite foreign keys.
  • Interactive Mode: Guides through configuration file generation and database connection setup.
  • Customizable Visualization: Allows customization of DBML file appearances with configurable color schemes.
  • SQL Comments Extraction: Extracts SQL table and column comments as DBML notes.
  • Table Statistics: Includes table statistics like row count and size in bytes in the DBML output.

Installation

Prerequisites

  • Python 3.6+
  • Snowflake account credentials

Install from PyPI

pip install snowflake-dbml-generator

Build from Source

git clone https://github.com/ryanrozich/snowflake-dbml-generator.git
cd snowflake-dbml-generator
pip install -e .

Usage

Command Line Interface

Run the generator via the command line. For detailed usage, see Configuration Parameters.

snowflake-dbml --user <username> --password <password> --account <account_id> --warehouse <warehouse> --database <database> --role <role>

Interactive Mode

For guided setup:

snowflake-dbml --interactive

Configuration Parameters

Configuration can be set via environment variables, a .env file, or command-line arguments. Learn more about setting configuration parameters.

Configuration File

For advanced setups, particularly when Snowflake does not enforce foreign key relationships, a config.json file can define how relationships are inferred. See Configuring Relationships for detailed setup.

Generating DBML

To generate a DBML file after setting up your configuration:

snowflake-dbml --config-file config.json > output.dbml

Contributing

Contributions are welcome! Whether it's tweaking code, enhancing documentation, or reporting bugs, we'd love to see your pull requests. Let's make this tool even better together!

Here’s a refined section for your README.md to document all special commit message keywords, including instructions for controlling version increments. This section can be integrated into your GitHub repository documentation:

Commit Message Keywords

In our continuous integration process, commit message keywords play a crucial role in determining the nature of changes and the corresponding actions in our deployment pipeline. Below are the keywords that you can use to control versioning and deployment:

Keywords:

  • [skip version]

    • Purpose: Prevents any version bump or tag creation. Use this keyword for commits that make non-functional changes, such as updates to documentation, that do not warrant a new version number.
    • Example:
      git commit -m "Update README [skip version]"
      
  • MAJOR:

    • Purpose: Triggers a major version bump, indicating backward-incompatible changes that require this level of escalation.
    • Example:
      git commit -m "MAJOR: Redesign database schema for scalability"
      
  • MINOR:

    • Purpose: Triggers a minor version bump, suitable for backward-compatible functionality enhancements.
    • Example:
      git commit -m "MINOR: Add new analytics features"
      
  • PATCH: (default if no keyword is specified)

    • Purpose: Applies a patch version bump, typically for bug fixes and minor changes that don’t add new features or break existing ones.
    • Example:
      git commit -m "PATCH: Fix data loading issue"
      

Workflow Integration:

These keywords are evaluated in our GitHub Actions workflow to decide the type of version bump or to skip versioning entirely. It ensures that our versioning reflects the nature of changes accurately, maintaining consistency and predictability in our release process.

By using these keywords appropriately in your commit messages, you help maintain the integrity of the versioning process and ensure that each release is meaningful.

License

Licensed under the MIT License - see the LICENSE file for details.

Author

Ryan Rozich - GitHub

Acknowledgments

Release files for snowflake-dbml-generator 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snowflake-dbml-generator 0.1.2
File Size Uploaded
snowflake-dbml-generator-0.1.2.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for snowflake-dbml-generator 0.1.2
File Interpreter ABI Platform
snowflake_dbml_generator-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / snowflake-dbml-generator-0.1.2.tar.gz

Download URL snowflake-dbml-generator-0.1.2.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d857d2fdb7ba20fcdb6db340e1ebbcce056ff4f4e8c00a33cb9f296fb080503c
BLAKE2b-256 checksum
How to use checksums
c0714c01c31b767a2045c6aa17e1e7902b4daff6ad3ffdb55560134283881509
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.9

Release files / snowflake_dbml_generator-0.1.2-py3-none-any.whl

Download URL snowflake_dbml_generator-0.1.2-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37838a943706bd273c4d56f7947dd2368038b974b81e4ce369fe72a0145b4f66
BLAKE2b-256 checksum
How to use checksums
0cc1e4bdac1ceee62387b0bb8bce95138151a1923bd85959899fdb4694bd6b4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page