Skip to content

Commit

Permalink
Get columns before fetching all rows
Browse files Browse the repository at this point in the history
  • Loading branch information
jlubken committed Feb 11, 2022
1 parent e1ab7b2 commit 0f04ed7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/dsdk/persistor.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def df_from_query_by_keys(
with NamedTemporaryFile("w", delete=False, suffix=".sql") as fout:
fout.write(rendered)
cur.execute(rendered)
rows = cur.fetchall()
columns = (each[0] for each in cur.description)
rows = cur.fetchall()
if rows:
df = DataFrame(rows)
df.columns = columns
Expand Down

0 comments on commit 0f04ed7

Please sign in to comment.