Skip to content

Commit

Permalink
Refactor returnAsDict query mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bhirsz committed Nov 5, 2023
1 parent dc7e762 commit d65523f
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/DatabaseLibrary/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,9 @@ def query(self, selectStatement, sansTran=False, returnAsDict=False):
logger.info("Executing : Query | %s " % selectStatement)
self.__execute_sql(cur, selectStatement)
allRows = cur.fetchall()

if returnAsDict:
mappedRows = []
col_names = [c[0] for c in cur.description]

for rowIdx in range(len(allRows)):
d = {}
for colIdx in range(len(allRows[rowIdx])):
d[col_names[colIdx]] = allRows[rowIdx][colIdx]
mappedRows.append(d)
return mappedRows

return [dict(zip(col_names, row)) for row in allRows]
return allRows
finally:
if cur:
Expand Down

0 comments on commit d65523f

Please sign in to comment.