Hello everybody ! I would like to trigger an SQLal...
# getting-started
b
Hello everybody ! I would like to trigger an SQLalchemy model property update each time records are created or updated on a specific table, populated by a Meltano pipeline with
target-postgres
. One solution would be to tweak
target-postgres
and either add to the code : (1) a postgres trigger, that would be executed each time a record is inserted or updated by
target-postgres
or (2) use postgres notifications built-in mecanism to broadcast
INSERT
or
UPDATE
events, that would trigger the SQLalchemy property update. Would there be a more low-touch solution, that does not involve forking
target-postgres
?
On 2nd thoughts, it could be more reliable and simple to add a job polling the bookmarks in the meltano state backend, for the relevant streams, and trigger the SQLalchemy model property update accordingly. Any experience on this latter idea from the awesome Meltano community would be awesome 😅
s
@benoit_lienart My intuition tells me, your SQLalchemy models should be able to do that on their own without you polling the bookmarks. After all, SQLalchemy is an ORM an object relational mapper made to do exactly these things. Maybe I'm misunderstanding your question?
b
@Sven Balnojan you are right to assume that an SQLalchemy model can emit events on an instance insert or update for another model to listen and process the events according to the business logic. The problem here is that the postgres records on the source table are managed by Meltano and outside of the scope of my SQLalchemy models, so I need a way to make Meltano and my SQLalchemy models talk to each other in some way...