如何判断您的select查询是否在一个事务中?

编程入门 行业动态 更新时间:2024-10-26 18:22:56
本文介绍了如何判断您的select查询是否在一个事务中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在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查询是否在一个事务中?

本文发布于:2023-10-25 14:28:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1527222.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:您的   如何判断   事务   select

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!