16 lines
475 B
Python
16 lines
475 B
Python
import sqlmodel
|
|
from sqlalchemy.future import Engine
|
|
|
|
from . import models
|
|
|
|
|
|
def get_engine(host: str, user: str, passwd: str, db: str) -> Engine:
|
|
"""Creates an engine for mariadb with pymysql as connector"""
|
|
engine = sqlmodel.create_engine(f"mariadb+pymysql://{user}:{passwd}@{host}/{db}")
|
|
return engine
|
|
|
|
|
|
def prepare(engine: Engine) -> None:
|
|
"""Creates all tables, indexes and constrains in the database"""
|
|
sqlmodel.SQLModel.metadata.create_all(engine)
|