mirror of
https://github.com/status-im/spiffworkflow-connector.git
synced 2025-02-23 03:58:08 +00:00
check if conn is set before attempting to close it w/ burnettk
This commit is contained in:
parent
ddd9284eef
commit
30bb4c6b97
@ -10,9 +10,8 @@ class ConnectionConfig:
|
|||||||
self.password = password
|
self.password = password
|
||||||
|
|
||||||
class BaseCommand:
|
class BaseCommand:
|
||||||
"""BaseCommand."""
|
|
||||||
|
|
||||||
def _execute(self, sql, conn_str, handler):
|
def _execute(self, sql, conn_str, handler):
|
||||||
|
conn = None
|
||||||
try:
|
try:
|
||||||
conn = psycopg2.connect(conn_str)
|
conn = psycopg2.connect(conn_str)
|
||||||
with conn.cursor() as cursor:
|
with conn.cursor() as cursor:
|
||||||
@ -27,7 +26,8 @@ class BaseCommand:
|
|||||||
status = 500
|
status = 500
|
||||||
response = f'{"error": "Error executing sql statement: {e}"}'
|
response = f'{"error": "Error executing sql statement: {e}"}'
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
if conn is not None:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
return {"response": response, "status": status, "mimetype": "application/json"}
|
return {"response": response, "status": status, "mimetype": "application/json"}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user