MySQL / PostgreSQL: how to call a script when a row inserted / updated
In Postgres, I would do this as a trigger that uses a foreign table to make the remote table appear as a local one. 

The trigger function can then query, update or join the remote table as if it was a local one and Postgres will be smart enough to push the work to the remote server (e.g. filtering, grouping, sorting etc). 

The table can also be updated directly from within the trigger, no need for some scripts outside the database 

If you prefer Python instead of PL/pgSQL you can write the trigger function in Python.