Skip to content

Commit 99c29ec

Browse files
authored
Merge pull request #6 from EncoreTechnologies/master
Generic query issues.
2 parents 95a7bdb + d32aac6 commit 99c29ec

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 0.1.2
4+
5+
- Fixed issue with generic query where connection was being closed before query results were returned.
6+
Contributed by Bradley Bishop (Encore Technologies)
7+
38
## v0.1.1
49

510
Pack bump to update files from master to a tagged release.

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

pack.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
ref: sql
33
name: sql
44
description: StackStorm Integration Pack for SQL Databases (Postgres, MySQL, etc)
5-
keywords:
5+
keywords:
66
- Postgres
7-
- MySQL
8-
- MsSQL
9-
version: 0.1.1
7+
- MySQL
8+
- MsSQL
9+
version: 0.1.2
1010
author: Encore Technologies
1111

0 commit comments

Comments
 (0)