From 56bc5f01adc6e9c639a8dcc8de15090c6b6b27cf Mon Sep 17 00:00:00 2001 From: Matt Hutton Date: Sun, 27 Oct 2024 18:00:03 +1300 Subject: [PATCH] fix #125: Close database connection after each query Each query creates a new DB connection. This change is to close each new connection rather than leaving them open, to allow for runs which involve large numbers of queries. --- things/database.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/things/database.py b/things/database.py index 68549c3..ab0a050 100755 --- a/things/database.py +++ b/things/database.py @@ -503,7 +503,9 @@ def execute_query(self, sql_query, parameters=(), row_factory=None): cursor = connection.cursor() cursor.execute(sql_query, parameters) - return cursor.fetchall() + result = cursor.fetchall() + connection.close() + return result # Helper functions