Added exception handling

This commit is contained in:
StNicolay 2022-10-05 14:52:23 +03:00
parent 6546fc0401
commit 91518559b0

View File

@ -1,15 +1,22 @@
import mariadb
import traceback
def add_master_pass(
id: int, hashed_passwd: bytes, salt: bytes, con: mariadb.Connection
) -> bool:
cursor = con.cursor()
try:
cursor.execute(
"INSERT INTO master_pass (user_id, salt, passwd) VALUES (?, ?, ?)",
[id, hashed_passwd, salt],
)
cursor.close()
except Exception:
traceback.print_exc()
return False
else:
return True
def add_account(
@ -21,8 +28,14 @@ def add_account(
con: mariadb.Connection,
) -> bool:
cursor = con.cursor()
try:
cursor.execute(
"INSERT INTO accounts (user_id, acc_name, salt, enc_login, enc_pass) VALUES (?, ?, ?, ?, ?, ?)",
[id, acc_name, salt, enc_login, enc_passwd],
)
cursor.close()
except Exception:
traceback.print_exc()
return False
else:
return True