mysql - 循环中的 Python mysql-connector SELECT 返回过时的结果
问题描述
我正在使用 mysql-connectorSELECT
在 while 循环中运行查询以查找新作业。
import mysql.connector
while True:
sql.execute("select id, mailing_list, account_list, template from dom_campaigns where status = 0")
campaigns = sql.fetchall()
如果我在表中插入一行并启动脚本,它会处理它。但是,如果我启动脚本,然后在脚本运行时插入一行,它永远不会因为fetchall()
. 我必须停止/启动脚本才能显示出来。
为什么要这样做,如果在脚本运行时插入行,我怎样才能让它获取行?
解决方案
推荐阅读
- python - 无法使用请求从网页中获取特定项目
- arrays - 为什么我的阵列在我推入它们后仍然是空的?
- python - 索引超出范围,用于减少嵌套列表的循环
- python - 如何从有条件的字典中提取值
- html - 使用 Bootstrap 4 在无限行内居中卡
- python - python删除所有重复项包括该元素
- jquery - 如何将 $scope.value 名称放入 $('input:radio[name="optradio"][value="$scope.t_color"]') .attr('checked', true);
- angular - Angular 8 - 自动刷新指令
- node.js - 反应原生 | 取消承诺 JSON Parse 错误
- javascript - 鼠标悬停随机颜色