I have several flask (python=3.10) applications running on my server (Ubuntu 20.04.6 LTS). They are, as of now, working great and being served via Apache and mod_wsgi. My requirements.txt is below.
For example, this is from the conf file in the sites-enabled directory:
WSGIDaemonProcess opinions threads=2 user=ray python-home=/home/ray/opinions/.venv home=/home/ray/opinions/
WSGIScriptAlias /opinions /home/ray/opinions/opinions.py
<Directory /home/ray/opinions/>
WSGIProcessGroup opinions
Require all granted
</Directory>
This app is using sqlalchemy to connect to a mysql database.
The problem is that if I want to dump into the database (with, for example, "mysqldump <db1> | mysql meetings"), I cannot do it without shutting off the flask application. AFAIK the way to do this is edit the conf file, comment out this app and restart apache. Then, after the data write, edit the conf file again, uncomment the app and restart apache again. It is a PITA to do this every time.
There are obvious reasons for flask to want to protect the data, but I want to be able to turn off this safety feature. I cannot just take the lock statements out of the SQL that is writing the data. That does not work.
Do I need to change something in my flask setup, my setup of the sqlalchemy connection, the mod_wsgi setup, or what? Any suggestions appreciated.
I see When a Flask application with Flask-SQLAlchemy is running, how do I use MySQL client on the same database at the same time? but wow that looks hack-ish. And old. Is this still the way?
$ cat requirements.txt
click==8.1.3
Flask==2.2.2
greenlet==2.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
PyMySQL==1.0.2
python-dotenv==0.21.0
SQLAlchemy==1.4.42
Werkzeug==2.2.2