我有一个 python 应用程序。 我想知道 mysql 中是否有任何功能(即事件或触发器)允许我在数据库中插入数据时通知我的 python 应用程序。 我想避免使用轮询,因为它会对我的数据库造成很大的开销。
最佳答案
它不是直接用于 Python,而是 Is there a way to watch a mysql database for changes using perl?给出了两个选项如何做到这一点:
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.
关于python - 从 MySQL 数据库推送功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26968656/