Reputation: 26859
I'm seeing some unexpected behaviour with Flask-SQLAlchemy, and I don't understand what's going on:
If I make a change to a record using e.g. MySQL Workbench or Sequel Pro, the running app (whether running under WSGI on Apache, or from the command line) isn't picking up the change. If I reload the app by touching the WSGI file, or by reloading it (command line), I can see the changed record. I've verified this by running an all()
query in the interactive shell, and it's the same – no change until I quit the shell, and start again. I get the feeling I'm missing something incredibly obvious here – it's a single table, no joins etc. – Running MySQL 5.5.19, and SQLA 0.7.7 on 2.7.3
Upvotes: 1
Views: 484
Reputation: 1790
you app's SELECT is probably within its own transaction / session so changes submitted by another session (e.g. MySQL Workbench connection) are not yet visible for your SELECT. You can easily verify it by enabling mysql general log or by setting 'echo: false' in your create_engine(...) definition. Chances are you're starting your SQLAlchemy session in SET AUTOCOMMIT = 0 mode which requires explicit commit or rollback (when you restart / reload, Flask-SQLAlchemy does it for you automatically). Try either starting your session in autocommit=true mode or stick explicit commit/rollback before calling your SELECT.
Upvotes: 1