Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Perl POE module for monitoring a database table for changes?

Tags:

perl

poe

Is there any Wheel /POCO /Option to do this in Perl using the POE module: I want to monitor a DB table for changed records (deleting /insert/ update) and react accordingly to those changes.

If yes could one provide some code or a link that shows this?

like image 791
dan Avatar asked Dec 18 '22 04:12

dan


1 Answers

Not that I'm aware of, but if you were really industrious you could write one. I can think of two ways to do it.

Better one first: get access to a transaction log / replication feed, e.g. the MySQL binlog. Write a POE::Filter for its format, then use POE::Wheel::FollowTail to get a stream of events, one for each statement that affects the DB. Then you can filter the data to find what you're interested in.

Not-so-good idea: using EasyDBI to run periodic selects against the table and see what changed. If your data is small it could work (but it's still prone to timing issues); if your data is big this will be a miserable failure.

like image 171
hobbs Avatar answered Apr 22 '23 16:04

hobbs