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/delete.py

30 lines
912 B
Python
Raw Normal View History

2022-10-14 14:48:32 +00:00
import sqlmodel
from sqlalchemy.future import Engine
from . import models
def purge_accounts(engine: Engine, user_id: int) -> None:
statement = sqlmodel.delete(models.Account).where(models.Account.user_id == user_id)
with sqlmodel.Session(engine) as session:
session.exec(statement)
2022-10-29 21:30:45 +00:00
session.commit()
2022-10-14 14:48:32 +00:00
def delete_master_pass(engine: Engine, user_id: int) -> None:
statement = sqlmodel.delete(models.MasterPass).where(
models.MasterPass.user_id == user_id
)
with sqlmodel.Session(engine) as session:
session.exec(statement)
2022-10-29 21:30:45 +00:00
session.commit()
def delete_account(engine: Engine, user_id: int, name: str) -> None:
statement = sqlmodel.delete(models.Account).where(
models.Account.user_id == user_id and models.Account.name == name
)
with sqlmodel.Session(engine) as session:
session.exec(statement)
2022-10-29 21:30:45 +00:00
session.commit()