How to disable SQLAlchemy caching?
The usual cause for people thinking there's a "cache" at play, besides the usual SQLAlchemy identity map which is local to a transaction, is that they are observing the effects of transaction isolation. SQLAlchemy's session works by default in a transactional mode, meaning it waits until session.commit()
is called in order to persist data to the database. During this time, other transactions in progress elsewhere will not see this data.
However, due to the isolated nature of transactions, there's an extra twist. Those other transactions in progress will not only not see your transaction's data until it is committed, they also can't see it in some cases until they are committed or rolled back also (which is the same effect your close() is having here). A transaction with an average degree of isolation will hold onto the state that it has loaded thus far, and keep giving you that same state local to the transaction even though the real data has changed - this is called repeatable reads in transaction isolation parlance.
http://en.wikipedia.org/wiki/Isolation_%28database_systems%29
How to disable caching correctly in Sqlalchemy orm session?
SQLAlchemy doesn't cache on itself. Unless you explicitly implemented a cache, like this one.
Pass echo=True
to your sessionmaker
and look into the logging
output.
Sqlalchemy returns stale rows?
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()
Related Topics
Calling Dot Products and Linear Algebra Operations in Cython
Python: Mocking a Context Manager
Deleting Multiple Columns Based on Column Names in Pandas
How to Remove Item from a Python List in a Loop
How to Install Pip3 on Windows
How to Bind the Enter Key to a Function in Tkinter
How to Output Cdata Using Elementtree
Why Is the Value of _Name_ Changing After Assignment to Sys.Modules[_Name_]
Why Is Using Thread Locals in Django Bad
Oserror: [Winerror 193] %1 Is Not a Valid Win32 Application
Receive and Send Emails in Python
How to Simulate Jumping in Pygame for This Particular Code
How to Make an Image with a Transparent Backround in Pygame
Pandas Sum by Groupby, But Exclude Certain Columns
How to Find Duplicate Elements in Array Using for Loop in Python