начало БД
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from my_loggers import *
|
||||
from for_DB import *
|
||||
from password import *
|
||||
@@ -0,0 +1,13 @@
|
||||
def toDict(data) -> dict:
|
||||
return {
|
||||
c.name: (
|
||||
(
|
||||
getattr(data, c.name)
|
||||
if not c.name.endswith("_data")
|
||||
else getattr(data, c.name).toDict()
|
||||
)
|
||||
if not c.name.endswith("_at")
|
||||
else getattr(data, c.name).strftime("%Y-%m-%d %H:%M:%S")
|
||||
)
|
||||
for c in data.__table__.columns
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import logging
|
||||
import logging.config
|
||||
|
||||
logging.config.fileConfig("config/log.ini")
|
||||
|
||||
# loggers
|
||||
logger = logging.getLogger("Tools Stock")
|
||||
loggerDB = logging.getLogger("DB operations")
|
||||
logger = logging.getLogger("UI operations")
|
||||
@@ -0,0 +1,18 @@
|
||||
from passlib.context import CryptContext
|
||||
|
||||
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
|
||||
|
||||
def pwd_hash(pwd_plant: str) -> str:
|
||||
return pwd_context.encrypt(pwd_plant)
|
||||
|
||||
|
||||
def pwd_verify(pwd_plant: str, pwd_hash: str) -> bool:
|
||||
from my_loggers import logger
|
||||
|
||||
try:
|
||||
return pwd_context.verify(pwd_plant, pwd_hash)
|
||||
except Exception as e:
|
||||
logger.error(f"Password verification error: {str(e)}")
|
||||
return False
|
||||
Reference in New Issue
Block a user