rodrigogs / mysql-events

A node package that watches a MySQL database and runs callbacks on matched events.
BSD 3-Clause "New" or "Revised" License
136 stars 52 forks source link

Is there any way to get the raw SQl statement that was executed during an event? #10

Closed sam26880 closed 5 years ago

sam26880 commented 5 years ago

I know that there's a new setting available as of MySQL 5.6.2 called binlog_rows_query_log_events which logs the raw SQL to the binlog.

Is there a way to get that value?

The reason why I need this is because the existing package lets me know that some event occurred. Such as INSERT, UPDATE or DELETE. However, it doesn't tell me what the 'WHERE' condition that was used in cases of UPDATE or DELETE.

It'd be good to get the raw sql in that case to know exactly which query was executed.

rodrigogs commented 5 years ago

You're able to catch raw events by using:

new MySQLEvents({ ... })
  .on(MySQLEvents.EVENTS.BINLOG, (event) => {
    doSomething(event);
  });

Check if those raw events have the info you're looking for.

sam26880 commented 5 years ago

I think you misunderstood me. I'm not talking about the raw events. I'm talking about the raw SQL. Does the event have the actual SQL that caused that INSERT, UPDATE or DELETE event?

rodrigogs commented 5 years ago

I don't remember, but if it has, it's on the raw binlog events. Sorry, but you'll have to check it :/

rodrigogs commented 5 years ago

Is it resolved?