Skip to content

Commit

Permalink
refactor: remove stage.py, do DB committing in fewer steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Oct 19, 2024
1 parent a68b542 commit 33b4392
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 300 deletions.
10 changes: 1 addition & 9 deletions docs/code-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,4 @@ If the `--snapshot-tables` argument is used, the analyzer will create a CSV file

## Database connector

The database connector code is located in `ferry/database`.

- `stage.py`: stages the data in the database.
- `deploy.py`: checks table invariants, and regenerates the database based on the staged data. At this step we also run SQL to generate some derived tables.

TODO:

1. Move the SQL logic to the data analyzer.
2. Ferry should not regenerate the whole DB each time.
The database connector code is located in `ferry/database`. It takes the Pandas tables and imports them into the database.
Binary file modified docs/db_diagram.pdf
Binary file not shown.
3 changes: 1 addition & 2 deletions ferry/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
course_flags,
course_professors,
)
from .stage import stage
from .deploy import deploy
from .sync_db import sync_db
5 changes: 0 additions & 5 deletions ferry/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ def __init__(self, connect_string: str):
"keepalives_count": 5,
},
)
Base.metadata.create_all(self.Engine)

if any(not table.endswith("_staged") for table in Base.metadata.tables):
raise MissingTablesError("Model tables should all end with _staged")

self.Session = sqlalchemy.orm.sessionmaker(bind=self.Engine)


Expand Down
139 changes: 0 additions & 139 deletions ferry/database/deploy.py

This file was deleted.

Loading

0 comments on commit 33b4392

Please sign in to comment.