I have a script that connects to DB and can get data from it Can I somehow make it to notify me, when any new record is added to the DB table
Solved this using sql triggers and go-pg
library:
Create sql function called insert_test_func
, that on INSERT
do:
PERFORM pg_notify('mychan', 'Message');
Create trigger, that executes func:
create trigger check_insert
before insert or update on *my_table_name*
for each row
execute procedure insert_test_func();
Execute this trigger
With github.com/go-pg/pg
, connect to the DB and with pg.Listen()
listening to the channel for the 'Message'
.