Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlalchemy returns "stale" rows?

I have a table (MySQL) with a row in it.

I can read it fine with:

self._session.query(Automatic).\
             filter(Automatic.do_when <= time()).\
             limit(limit).\
             all()

However, if I then delete the row from table (with the mysql client or phpMyAdmin), the row is still returned by the code above. I don't know if this is related to the question "How to disable SQLAlchemy caching?".

Edit: Adding a

self._session.commit()

after makes no difference.

like image 672
Prof. Falken Avatar asked May 16 '13 11:05

Prof. Falken


Video Answer


1 Answers

Edit: Adding commit() before reading did the trick, as per eggyal's explanation.

self._session.commit()
self._session.query(Automatic).\
             filter(Automatic.do_when <= time()).\
             limit(limit).\
             all()
like image 122
Prof. Falken Avatar answered Sep 29 '22 17:09

Prof. Falken