Skip to content

Commit 5f8b13a

Browse files
committed
Moved code to print rows to be executed while connection is still open.
1 parent 3afdf16 commit 5f8b13a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

actions/generic_query.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ def run(self, **kwargs):
1818

1919
query = self.get_del_arg('query', kwargs_dict)
2020

21+
return_result = None
2122
with self.db_connection(kwargs_dict) as conn:
2223
# Execute the query
2324
query_result = conn.execute(query)
2425

25-
return_result = {'affected_rows': query_result.rowcount}
26-
if query_result.returns_rows:
27-
return_result = []
28-
all_results = query_result.fetchall()
29-
for row in all_results:
30-
# Rows are returned as tuples with keys.
31-
# Convert that to a dictionary for return
32-
return_result.append(self.row_to_dict(row))
26+
# We need to execute these commands while connection is still open.
27+
return_result = {'affected_rows': query_result.rowcount}
28+
if query_result.returns_rows:
29+
return_result = []
30+
all_results = query_result.fetchall()
31+
for row in all_results:
32+
# Rows are returned as tuples with keys.
33+
# Convert that to a dictionary for return
34+
return_result.append(self.row_to_dict(row))
3335

3436
return return_result

0 commit comments

Comments
 (0)