When I run a Flask application which is using Flask-SQLAlchemy, it seems that Flask-SQLAlchemy is holding a session and when I issue a MySQL command, like alter table add column, in MySQL client terminal, the commands cannot be executed until I quit the Flask application.
Does anybody have similar experience? How can I issue commands on MySQL client without interrupting the Flask application?
You may want to look at this question SQL Alchemy Relationship loader leaves a lock on table?
What you'll need to do is subclass flask.ext.sqlalchemy.SQLAlchemy
and override the apply_driver_hacks
method to pass through the additional keyword argument isolation_level='READ <some level>'
:
from flask.ext.sqlalchemy import SQLAlchemy
class UnLockedAlchemy(SQLAlchemy):
def apply_driver_hacks(self, app, info, options):
if not "isolation_level" in options:
options["isolation_level"] = "READ COMMITTED" # For example
return super(UnLockedAlchemy, self).apply_driver_hacks(app, info, options)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With