1

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

asked May 18, 2012 at 1:57
1
  • This is a Session issue, isn't it. Bah. Commented May 18, 2012 at 2:29

1 Answer 1

1

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.

answered Mar 4, 2013 at 4:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.