3

有没有什么方法可以实时检测 mysql 数据库中某个值是否发生改变?

 3 years ago
source link: https://www.v2ex.com/t/797361
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

有没有什么方法可以实时检测 mysql 数据库中某个值是否发生改变?

  Ackvincent · 1 小时 0 分钟前 · 136 次点击

我现在是用一个 while 循环每隔一秒钟查询一次来判断的,有没有什么其他方法可以实现这个需求? 谢谢

5 条回复    2021-08-23 00:57:13 +08:00

lishunan246

lishunan246   56 分钟前 via Android

canal

mtrec

mtrec   32 分钟前

不如说说你想干什么以及你现在的做法有什么让你不满的地方

qiyuey

qiyuey   30 分钟前 via Android

监听 binlog

dorothyREN

dorothyREN   28 分钟前

设置个更新操作的触发器,然后触发器里面判断有没有更新这个值。

Ackvincent

Ackvincent   3 分钟前

@lishunan246
@mtrec
@qiyuey
@dorothyREN
我现在代码是这样 感觉很蠢得样子
```python
while True:
print('start check')
action = mysql.get_action()
if action == 'turn_on':
turn_on_the_light()
elif action == ''turn_off':
turn_off_the_light()
else:
time.sleep(1)
continue

```

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK