from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

# Base Table class, ArchivedFile and FilePackage are extending this class
Base = declarative_base()

class Database():
    def __init__(self, config: dict) -> None:
        self.user = config["database"]["user"]
        self.host = config["database"]["host"]
        self.port = config["database"]["port"]
        self.password = config["database"]["password"]
        self.database = config["database"]["database"]
        self.engine = create_engine(f"mariadb+mariadbconnector://{self.user}:{self.password}@{self.host}:{self.port}/{self.database}")
        self.Session = sessionmaker(bind=self.engine)