Skip to content

Commit

Permalink
Rework ER diagram to just use felis
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-rodriguez committed Dec 11, 2024
1 parent d36abc4 commit 30c401d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scripts/make_erd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

import sys

from astrodbkit.astrodb import Database, create_database
import yaml
from eralchemy2 import render_er
from felis.datamodel import Schema
from felis.metadata import MetaDataBuilder

sys.path.append("./") # needed for github actions to find the template module
from schema.schema_template import REFERENCE_TABLES

# Connect to an in-memory sqlite database
create_database(connection_string="sqlite://", felis_schema="schema/schema.yaml")
db = Database("sqlite://", reference_tables=REFERENCE_TABLES)
# Load up schema
data = yaml.safe_load(open("schema/schema.yaml", "r"))
schema = Schema.model_validate(data)

# Create from Felis schema
metadata = MetaDataBuilder(schema).build()

# Create ER model from the database metadata
filename = "schema/schema.png"
render_er(db.metadata, filename)
render_er(metadata, filename)

0 comments on commit 30c401d

Please sign in to comment.