From 2449f1960b8fc5a96a6086b2a9fa6efd5b9cd7af Mon Sep 17 00:00:00 2001 From: Felipe Hertzer Date: Tue, 12 Sep 2023 23:59:03 +1000 Subject: [PATCH] Close Cursor and Close DB when Commit MySQLConnection.py --- src/masoniteorm/connections/MySQLConnection.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/masoniteorm/connections/MySQLConnection.py b/src/masoniteorm/connections/MySQLConnection.py index 762e85e0..386145db 100644 --- a/src/masoniteorm/connections/MySQLConnection.py +++ b/src/masoniteorm/connections/MySQLConnection.py @@ -105,6 +105,9 @@ def commit(self): """Transaction""" self._connection.commit() self.transaction_level -= 1 + if self.get_transaction_level() <= 0: + self.open = 0 + self._connection.close() def dry(self): """Transaction""" @@ -169,6 +172,7 @@ def query(self, query, bindings=(), results="*"): except Exception as e: raise QueryException(str(e)) from e finally: + self._cursor.close() if self.get_transaction_level() <= 0: self.open = 0 self._connection.close()