Рефакторинг

This commit is contained in:
Anton Kamalov
2024-10-22 01:38:20 +03:00
parent d1f513e106
commit 6d8973487f
10 changed files with 19 additions and 31 deletions

12
App/Database/select.py Normal file
View File

@@ -0,0 +1,12 @@
from .DBconnect import DBContextManager
def select_list(db_config, sql):
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 schema, lst