Filled delete.py and created change.py
This commit is contained in:
parent
85129d8b7a
commit
7fe7b23a63
@ -1,3 +1,3 @@
|
|||||||
from . import add, delete, get, models, prepare
|
from . import add, delete, get, models, prepare, change
|
||||||
|
|
||||||
__all__ = ["add", "delete", "get", "models", "prepare"]
|
__all__ = ["add", "delete", "get", "models", "prepare", "change"]
|
||||||
|
16
src/database/change.py
Normal file
16
src/database/change.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import sqlmodel
|
||||||
|
from sqlalchemy.future import Engine
|
||||||
|
|
||||||
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
|
def change_master_pass(
|
||||||
|
engine: Engine, user_id: int, salt: bytes, passwd: bytes
|
||||||
|
) -> None:
|
||||||
|
statement = sqlmodel.update(
|
||||||
|
models.MasterPass,
|
||||||
|
models.MasterPass.user_id == user_id,
|
||||||
|
sqlmodel.values(salt=salt, passwd=passwd),
|
||||||
|
)
|
||||||
|
with sqlmodel.Session(engine) as session:
|
||||||
|
session.exec(statement)
|
@ -0,0 +1,18 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
Reference in New Issue
Block a user