Monitoring mysql database and table updates using C# polling method
I need to monitor MySql database and log the delete, update, etc. operations done or not?
I have many tables in my Myhr database, but want to create a console application, which monitor Myhr db and check if there is any update or deletion is done. If yes, then it must return that value(the operation done).
Code samples will be of great use.
解决方案This is not really a question, it more a list of requirements and you asking for some code so save you trying to do it. I suggest that you read the FAQ on how to ask questions on this forum as it will guide you towards asking questions that you are more likely to get solutions to.
As for your problem, what about using Triggers on the database.
Mysql Triggers[^]
You could set up a trigger on every table in your database to update a log table with any changes. Personally I think it is over kill to have to monitor EVERY table.
But without knowing your database design it is not easy to advise. I also cannot see a reason for needing this sort of monitoring?
An alternative to the triggers, is that each time your application saves data, it writes an entry to the log table and you just poll the log table on a regular basis to see if there are new entries. Again, this removes the need to monitor every table but just monitor 1.
This sounds like a disaster in the making, the first question that come to mind is WHY.
If MySQL supports triggers then insert the changes into a log table and query the log table.
We use this to keep and audit of changes but I would never consider polling the table. We allow the user to query the log table based on a bunch of criteria.