S
S
shushpanio2019-05-22 12:43:30
PostgreSQL
shushpanio, 2019-05-22 12:43:30

Is it possible to implement the launch of bash on the fact of an insert in the database?

Good afternoon.
I can not understand in any way in which direction I should dig.
There is a Wishlist: when writing a new line to the table / updating an existing one, run a trigger on which a bash script will be called that sends a message to the chat.
Is it possible to implement this in Postgres, and if possible, in which direction to dig? Who can faced similar and will advise docks on this question?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
O. J, 2019-05-22
@shushpanio

the most gentlemanly option is to implement the functionality you need in the project code that sends insert / update to the database, for this you will just need to hang an observer insert / update on the model associated with the table you need. If this is not possible, then through the trigger something like this.

CREATE or REPLACE FUNCTION NotifyTelegram() RETURNS text AS '
#!/bin/bash
echo say: $1 зачем тебе все это?
' LANGUAGE plsh;

-- или AFTER
CREATE TRIGGER TriggerBefore BEFORE INSERT OR UPDATE ON table_observed
    FOR EACH ROW EXECUTE PROCEDURE NotifyTelegram();

If there are jedi postgres correct me.
But the whole idea of ​​pulling bash from a trigger doesn't look very good.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question