Coder Social home page Coder Social logo

dicklesworthstone / sqlalchemy_data_model_visualizer Goto Github PK

View Code? Open in Web Editor NEW
233.0 2.0 8.0 59 KB

Automatically turn your SQLalchemy Data Models into a Nice SVG Diagram

License: MIT License

Python 100.00%
datamodel orm orm-model schema sqlalchemy visualization

sqlalchemy_data_model_visualizer's Introduction

SQLAlchemy Data Model Visualizer

Overview

This Python-based utility generates high-quality, readable visualizations of your SQLAlchemy ORM models with almost no effort. With a focus on clarity and detail, it uses Graphviz to render each model as a directed graph, making it easier to understand the relationships between tables in your database schema.

Example Data Model Diagram

Try it Out Easily in Colab:

Open In Colab

Features

  • Automatically maps SQLAlchemy ORM models to a directed graph.
  • Table-like representation of each model with fields, types, and constraints.
  • Export diagrams to SVG format for high-quality viewing and printing using Roboto font.

Installation with pip and Usage:

pip install sqlalchemy-data-model-visualizer

# Suppose these are your SQLAlchemy data models defined above in the usual way, or imported from another file:
models = [GenericUser, Customer, ContentCreator, UserSession, FileStorage, ServiceRequest, GenericAuditLog, GenericFeedback, GenericAPIKey, GenericNotification, GenericAPICreditLog, GenericSubscriptionType, GenericSubscription, GenericSubscriptionUsage, GenericBillingInfo]
output_file_name = 'my_data_model_diagram'
generate_data_model_diagram(models, output_file_name)
add_web_font_and_interactivity('my_data_model_diagram.svg', 'my_interactive_data_model_diagram.svg')

Installation from Source

To get started, clone the repository and install the required packages.

git clone https://github.com/Dicklesworthstone/sqlalchemy_data_model_visualizer.git
cd sqlalchemy_data_model_visualizer
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install wheel
pip install -r requirements.txt

Requirements

  • Python 3.x
  • SQLAlchemy
  • Graphviz
  • lxml

Usage

Generate Data Model Diagram

First, paste in your SQLAlchemy models. A set of fairly complex data models are provided in the code directly as an example-- just replace these with your own from your application.

Then, simply call the generate_data_model_diagram function. This will generate an SVG file with the name my_data_model_diagram.svg.

API Documentation

generate_data_model_diagram(models, output_file='my_data_model_diagram', add_labels=True)

  • models: List of SQLAlchemy models you want to visualize.
  • output_file: Name of the output SVG file.
  • add_labels: Set to False to hide labels on the edges between tables

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.