начало БД

This commit is contained in:
2025-11-29 14:51:45 +03:00
parent c48d1ee383
commit c59db5819f
23 changed files with 713 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
from my_loggers import *
from for_DB import *
from password import *
+13
View File
@@ -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
}
+9
View File
@@ -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")
+18
View File
@@ -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