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
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
You can use LISTEN/NOTIFY features of Postgresql.
With "github.com/lib/pq", you can easily fetch notify-events and react to new database-events.
Here is an example of the go implementation.
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'.