1

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?

Thanks in advance!

1
  • Why not use pull instead of push? if this is a specific row, just query it for changes every X minutes/seconds. If these could be many rows, create a flag table and add UPDATE triggers to alter the flag there, and your python application will poll for changes and set the flag back... Commented Apr 9, 2013 at 20:02

2 Answers 2

4

What about a cron job instead of create a loop? I think it's a bit nicer.

Sign up to request clarification or add additional context in comments.

Comments

3

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?

4 Comments

It sounds like UDF is the only way to do it. I just don't really want to make a loop because it seems like it could really burden the database with overhead. I was hoping to make it check more intelligently. My inspiration is kinda like Dropbox. It only syncs when it gets changes.
If all you are doing is select my_column from my_table where ... you're not really burdening the DB
Really? If that is true, this is a simple solution.
user2112825 is right, because MySQL has been designed to handle a large number of operations simultaneously, this would hardly affect the functioning of your database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.