import sqlmodel
import mariadb
from sqlalchemy.future import Engine
from . import models
def add_account(
engine: Engine,
user_id: int,
name: str,
salt: bytes,
enc_login: bytes,
enc_pass: bytes,
) -> bool:
account = models.Account(
user_id=user_id, name=name, salt=salt, enc_login=enc_login, enc_pass=enc_pass
)
try:
with sqlmodel.Session(engine) as session:
session.add(account)
session.commit()
except Exception:
return False
else:
return True
def add_master_pass(engine: Engine, user_id: int, salt: bytes, passwd: bytes) -> bool:
master_pass = models.MasterPass(user_id=user_id, salt=salt, passwd=passwd)
session.add(master_pass)