12 lines
438 B
Python
12 lines
438 B
Python
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 |