This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
PassManager/src/database/prepare.py

17 lines
424 B
Python
Raw Normal View History

2022-10-14 12:38:03 +00:00
import sqlmodel
from sqlalchemy.future import Engine
2022-09-26 19:44:48 +00:00
2022-10-14 12:38:03 +00:00
from . import models
2022-09-26 19:44:48 +00:00
2022-10-14 12:38:03 +00:00
def get_engine(host: str, user: str, passwd: str, db: str) -> Engine:
engine = sqlmodel.create_engine(
f"mariadb+mariadbconnector://{user}:{passwd}@{host}/{db}"
2022-09-26 19:44:48 +00:00
)
2022-10-14 12:38:03 +00:00
print(type(engine))
return engine
2022-09-26 19:44:48 +00:00
2022-10-14 12:38:03 +00:00
def prepare(engine: Engine) -> None:
2022-10-14 12:41:55 +00:00
sqlmodel.SQLModel.metadata.create_all(engine, [models.Account, models.MasterPass])