Fix in Requests + in Report part

This commit is contained in:
2024-11-14 19:19:48 +03:00
parent 7d939ef1e4
commit 19d5ce088e
18 changed files with 222 additions and 54 deletions

23
App/Report/db/work.py Normal file
View File

@@ -0,0 +1,23 @@
from .DBconnect import DBContextManager
def select_list(db_config, sql) -> list:
with DBContextManager(db_config) as cursor:
if cursor is None:
raise ValueError("Cursor not created")
else:
cursor.execute(sql)
result = cursor.fetchall()
schema = [item[0] for item in cursor.description]
lst = [dict(zip(schema, row)) for row in result]
return lst
def procedure(db_config, name, args: tuple):
with DBContextManager(db_config) as cursor:
if cursor is None:
raise ValueError("Cursor not created")
else:
cursor.callproc(name, args)
result = cursor.fetchall()[0]
schema = cursor.description[0]
lst = dict(zip(schema, result))
return lst