擅长:python、mysql、java
<p>如果您没有访问远程数据库服务器的权限,那么可能没有。你知道吗</p>
<p>您可以运行cronjob(或任何计划任务),定期检查数据库并运行相应的脚本,但数据库更改与脚本运行之间会有延迟,具体取决于它运行的频率。你知道吗</p>
<p>编辑(4/2/2019)</p>
<p>我认为<a href="https://dev.mysql.com/doc/refman/8.0/en/triggers.html" rel="nofollow noreferrer">trigger</a>不是正确的解决方案。触发器用于在执行某些操作时在内部运行查询,而不是触发外部脚本。可能有办法做到这一点,但我不熟悉任何,所以我不能给任何建议。你知道吗</p>
<p>我推荐两种选择之一:</p>
<ol>
<li><p>编写一个python脚本,定期检查数据库(称为<a href="https://en.wikipedia.org/wiki/Polling_(computer_science)" rel="nofollow noreferrer">polling</a>)中的LED状态,并与raspberry pi交互以更新LED。</p></li>
<li><p>把你的数据库放在一个API后面,这个API可以同时更新数据库和LED,并且改变任何正在直接更新LED状态数据库的东西来代替与API交互。<a href="http://flask.pocoo.org/" rel="nofollow noreferrer">Flask</a>是一个很好的pythonweb框架,可以使用<a href="http://docs.python-requests.org/en/master/" rel="nofollow noreferrer">requests</a>包与之交互。</p></li>
</ol>
<p>我建议选择1,但选择2更容易实施。两种解决方案都可以从你的树莓皮。你知道吗</p>