I have a python application. I wanted to know whether there is any functionality(i.e. event or trigger) in mysql which will allow me to notify my python application when data is inserted in the database. I would like to avoid the use of polling because it will cause a large overhead on my database.
2 Answers
It's not directly for Python,but Is there a way to watch a mysql database for changes using perl? gives two option how to do that:
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.
Hint:
- Websockets
- DB trigger send directly over websockets
Note:
DB trigger can write to file.
File could be read.
File could be pipe.
File content.
Content to be send.
Send over websockets.
And this is Happy End.
We're going to Week End.William Shakespeare :)
(source: biography.com)
Bibliography:
noplay/python-mysql-replication · GitHub Link
WebSocket.org | Echo Test Link
websockets 2.3 : Python Package Index Link
Kaazing Web & Mobile Communication Products Link
(Mandatory) Kaazing Developer Network | Telemetry Link
Kaazing Developer Network Link
Socket.IO Link
Message-oriented middleware - Wikipedia, the free encyclopedia Link
WebSocket Examples — AutobahnPython 0.9.2 documentation Link

- 21,988
- 13
- 81
- 109