Prof. Falken
Prof. Falken

Reputation: 24867

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.

Upvotes: 9

Views: 3836

Answers (1)

Prof. Falken
Prof. Falken

Reputation: 24867

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()

Upvotes: 17

Related Questions