db module for Auth

This commit is contained in:
2024-11-14 15:16:39 +03:00
parent 28ec057726
commit 751fb0c20d
5 changed files with 2 additions and 2 deletions

12
App/Auth/db/select.py Normal file
View File

@@ -0,0 +1,12 @@
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