[英]Python Real-time Busy Polling a Database
I have a database table that gets row/record INSERTS
from a third-party application. 我有得到行/记录数据库表INSERTS
从第三方应用程序。 This table has one column labeled 'active' that is always False
when each new record is INSERTED by the third-party application. 该表具有标记为“活动”的一列,当第三方应用程序插入每个新记录时,该列始终为False
。
My application needs to read rows on that database table, and find those rows that have the 'active' column with a Boolean value of False
and then UPDATE the column to True
(after doing some processing on the row). 我的应用程序需要读取该数据库表上的行,并找到带有布尔值False
的“活动”列的那些行,然后将该列更新为True
(在对该行进行一些处理之后)。
What is the best way to do this? 做这个的最好方式是什么? Right now I just have a simple while loop that repeatedly queries the database and processes that table. 现在,我只有一个简单的while循环,该循环重复查询数据库并处理该表。 But I think there must be a better way. 但是我认为必须有更好的方法。
My question is: What is the proper way to busy-poll a database in Python so that my application notices changes to the DB as soon as possible? 我的问题是:用Python忙轮询数据库以使我的应用程序尽快注意到数据库更改的正确方法是什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.