0

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
5
  • Can you try running the dump in a transaction and skipping the default table locking behavior as described here? Commented Apr 6, 2023 at 20:35
  • Nope. I did the mysqldump with --skip-lock-tables and it made no difference. I still cannot load the data without stopping the app. Commented Apr 7, 2023 at 23:01
  • Did you also wrap it in a transaction? Commented Apr 7, 2023 at 23:02
  • Hm. I am not sure why I would need to. But I will try that also. Commented Apr 8, 2023 at 21:58
  • Adding the transaction to the mysqldump does not help. Commented Apr 12, 2023 at 3:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.