MasoniteFramework / orm

Masonite ORM is a beautiful Python ORM. It's also a nearly drop in replacement of the Orator ORM
https://orm.masoniteproject.com
MIT License
160 stars 47 forks source link

MySQL Close cursor and connection on commit #857

Closed felipehertzer closed 9 months ago

felipehertzer commented 9 months ago

Hi @josephmancuso,

I'm having issues with lots of timeouts/open connections, where it seems like the connection isn't being closed.

I was checking MySQLConnection, and I saw that it never closes the cursor, I believe it could cause a memory leak.

I also identified that if I use transactions it will never close the connection, because the code is checking to close the connection in the query function and not in the commit function. Example:

DB.begin_transaction()
QueryBuilder().table('user').update('status', 1)
DB.commit()

This is pull request is an idea, I'm happy to discuss any solution.

Thanks.