且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在连续循环脚本中,数据库数据中的更改未反映在Django查询集中

更新时间:2023-02-12 10:02:23

这与缓存无关。

默认情况下,连续运行的脚本在单个事务中运行,因此永远不会在该事务之外看到更改。您需要在每次迭代中手动启动新事务-请参见交易文档有关如何操作的信息。

A continuously-running script by default runs within a single transaction, and so will never see changes outside that transaction. You'll need to start a new transaction manually on every iteration - see the transaction documentation on how to do that.