当SQL表中的值发生变化时如何执行Python函数? [英] How to execute Python function when value in SQL table changes?

查看:76
本文介绍了当SQL表中的值发生变化时如何执行Python函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在互联网上的任何地方找到这个答案.我希望能够监视 MySQL 表中的一行是否发生更改,当发生这种情况时,运行 Python 函数.我要运行的这个Python函数与MySQL无关;它只是在 Raspberry Pi 上启用一个引脚.我曾尝试研究 SQLAlchemy;但是,我不知道它是触发器还是数据映射.这样的事情有可能吗?

I am having trouble finding this answer anywhere on the internet. I want to be able to monitor a row in a MySQL table for changes and when this occurs, run a Python function. This Python function I want to run has nothing to do with MySQL; it just enables a pin on a Raspberry Pi. I have tried looking into SQLAlchemy; however, I can't tell if it is a trigger or a data mapping. Is something like this even possible?

提前致谢!

推荐答案

做一个循环,不断检查 MySQL 表中该行的值,当值发生变化时,调用要执行的函数.你也可以参考python:如何获取mysql数据库的通知变化?

make a loop which keeps checking the value of that row in MySQL table,the moment the value changes, call the function you want to execute. you can also refer to python: how to get notifications for mysql database changes?

这篇关于当SQL表中的值发生变化时如何执行Python函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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