Skip to content

Commit

Permalink
Merge pull request #857 from felipehertzer/2.0
Browse files Browse the repository at this point in the history
MySQL Close cursor and connection on commit
  • Loading branch information
josephmancuso authored Sep 30, 2023
2 parents d9c8e13 + 5d47746 commit 1adac4b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/masoniteorm/connections/MySQLConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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()

0 comments on commit 1adac4b

Please sign in to comment.