在Django 1.5.x中,我有一个长时间运行的管理命令,其中select查询返回陈旧的数据。我怀疑这是因为它们在早期在db连接上启动的事务中运行。有没有办法告诉一个查询是在一个事务中运行还是处于自动提交模式?
In Django 1.5.x, I have a long running management command where select queries are returning stale data. I suspect this is due to the fact that they are running within a transaction that are started earlier on the db connnection. Is there a way a tell if a query runs within a transaction or it is in autocommit mode?
(这是一个较为重点的版本, a href =stackoverflow/questions/18540099/orm-does-not-return-recent-database-changes> stackoverflow/questions/18540099/orm-does-not-return -recent-database-changes )
(this is somewhat more focused version of an earlier question I posted at stackoverflow/questions/18540099/orm-does-not-return-recent-database-changes)
推荐答案您可以通过检查 is_managed
if transaction.is_managed(): print "tutsi frutsi!"更多推荐
如何判断您的select查询是否在一个事务中?
发布评论