A
A
Alexander Karabanov2021-02-08 10:34:09
MySQL
Alexander Karabanov, 2021-02-08 10:34:09

How to intercept input in mysqlsh?

Hello.

There is a need to confirm DELETE , TRUNCATE , etc. operations. through the Slack bot, that is, when an attempt is made to perform a destructive operation, the bot must send a notification to interested parties who will allow / deny the request.

Can you please tell me if there is a way to intercept input using the mysqlsh plugin to send it to the bot?

I looked in the documentation, read the plugin sources, but did not see a way to implement it...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Karabanov, 2021-02-17
@karabanov

I even wrote to the "central" mysqlsh developer... There is no way to intercept input.
In general, I wrote a shell imitation in Python - it works, in general, as intended.

S
Swartalf, 2021-02-08
@Swartalf

> which allow/prohibit execution of the request.
and leave a transaction hanging with a full table lock? well, like that.
I would do it through triggers (I don’t remember if I can create a trigger in Mysql for the trunk operation, but it will definitely work for deletion).
By the delete trigger, a backup of the old data is made by copying to another table + you can insert it into the table for the bot, with which it will understand that you need to send a message about the fact that the desired event has occurred. well, there, after the fact of the message, it will be possible to understand what data was deleted, whether it is necessary to restore it, and what kind of logging.
but here you should not forget that the trigger is an additional load on the base + there may be nuances

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question