pgcom.listener.Listener.create_trigger

Listener.create_trigger(table_name: str, func_name: str, trigger_name: Optional[str] = None, when: str = 'AFTER', event: str = 'INSERT', for_each: str = 'STATEMENT') None[source]

Create trigger.

Creates a new trigger associated with the table and executed the specified function when certain events occur.

Parameters
  • table_name – The name of the table the trigger is for.

  • func_name – A user-supplied function, which is executed when the trigger fires.

  • trigger_name – The name to give to the new trigger. If not specified, then the automatically created name will be assigned.

  • when – One of “BEFORE”, “AFTER”, “INSTEAD OF”. Determines when function is called.

  • event – One of “INSERT”, “UPDATE”, “DELETE”, “TRUNCATE”. Use “OR” for event combinations, e.g. “INSERT OR UPDATE”.

  • for_each – One of “ROW”, “STATEMENT”. This specifies whether the trigger should be fired once for every row affected by the event, or just once per SQL statement.