Snippets Collections
from os import environ, remove
from pathlib import Path

from dotenv import find_dotenv, load_dotenv
from sqlalchemy import MetaData
from sqlalchemy_schemadisplay import create_schema_graph

load_dotenv(find_dotenv())
DB_NAME = environ.get("DB_NAME")
DB_PASS = environ.get("DB_PASS")
DB_USER = environ.get("DB_USER")
DB_HOST = environ.get("DB_HOST")
SQLALCHEMY_DATABASE_URL = (
    f"postgresql://{DB_USER}:{DB_PASS}@{DB_HOST}:5432/{DB_NAME}"
)


if __name__ == "__main__":
    FILE_NAME = 'ERD.png'
    try:
        os.remove(FILE_NAME)
    except:
        pass
    graph = create_schema_graph(metadata=MetaData(
        SQLALCHEMY_DATABASE_URL))
    graph.write_png(FILE_NAME)
star

Wed Oct 05 2022 12:49:26 GMT+0000 (UTC)

#erd #sql

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension