Changes to db: fixed error in __init__, looking for more precise errors
This commit is contained in:
parent
b60579ecd6
commit
85129d8b7a
@ -1,5 +1,5 @@
|
||||
import sqlmodel
|
||||
import mariadb
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.future import Engine
|
||||
|
||||
from . import models
|
||||
@ -21,7 +21,7 @@ def add_account(
|
||||
with sqlmodel.Session(engine) as session:
|
||||
session.add(account)
|
||||
session.commit()
|
||||
except Exception:
|
||||
except IntegrityError:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@ -34,7 +34,7 @@ def add_master_pass(engine: Engine, user_id: int, salt: bytes, passwd: bytes) ->
|
||||
with sqlmodel.Session(engine) as session:
|
||||
session.add(master_pass)
|
||||
session.commit()
|
||||
except Exception:
|
||||
except IntegrityError:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -13,4 +13,7 @@ def get_engine(host: str, user: str, passwd: str, db: str) -> Engine:
|
||||
|
||||
|
||||
def prepare(engine: Engine) -> None:
|
||||
sqlmodel.SQLModel.metadata.create_all(engine, [models.Account, models.MasterPass])
|
||||
sqlmodel.SQLModel.metadata.create_all(
|
||||
engine,
|
||||
# [models.Account, models.MasterPass]
|
||||
)
|
||||
|
Reference in New Issue
Block a user