-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
34 lines (20 loc) · 854 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from src.app_config import AppConfig
from src.update_worker import UpdateWorker
from pathlib import Path
from src.application import Application
from src.data_repository import DataRepository
from src.data_entities import Base
def initialize_database(file_path: str) -> DataRepository:
engine = create_engine(file_path)
Base.metadata.create_all(engine)
session_maker = sessionmaker(expire_on_commit=False)
session_maker.configure(bind=engine)
return DataRepository(session_maker)
if __name__ == "__main__":
config = AppConfig.read_from_file(Path(__file__).with_name("config.json"))
repository = initialize_database(config.database_path)
app = Application(config, repository)
UpdateWorker(repository).start()
app.mainloop()