有没有办法观看mysql数据库的更改使用perl? [英] Is there a way to watch a mysql database for changes using perl?

查看:164
本文介绍了有没有办法观看mysql数据库的更改使用perl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个类似于inotify方法观察文件的更改的解决方案。我知道我可以看到mysql数据库的binlog文件,并运行查询来挑选新的结果,但是这似乎非常低效和不雅;

I'm looking for a solution similar to the inotify method of watching files for changes. I'm aware that I could watch the binlog file of the mysql database and run queries to pick out the new results but that seems very inefficient and inelegant; as does simply doing masses of queries in a loop waiting for new results.

推荐答案

如果添加 TRIGGER 到您感兴趣的表格,您可以使用它来提醒观看的应用程序。您可以通过多种方式实现:

If you add a TRIGGER to the table(s) you're interested in, you can use that to alert the watching application. You could do that in a number of ways:


  1. 在数据库中创建审计表,并使触发器在其中写入相关信息;并让您的监视应用程序轮询审计表以获取新条目。

  2. 拥有触发器通过UDF调用外部应用

  1. Create an audit table in the database, and have the trigger write the relevant info there; and have your watching application poll the audit table for new entries. You're still polling, but in a controlled way which won't hit the server too hard.
  2. Have the trigger call an external app through a UDF.

这篇关于有没有办法观看mysql数据库的更改使用perl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆