airflow.providers.common.sql.triggers.sql

Classes

SQLExecuteQueryTrigger

A trigger that executes SQL code in async mode.

Module Contents

class airflow.providers.common.sql.triggers.sql.SQLExecuteQueryTrigger(sql, conn_id, hook_params=None, **kwargs)[source]

Bases: airflow.triggers.base.BaseTrigger

A trigger that executes SQL code in async mode.

Parameters:
  • sql (str | list[str]) – the sql statement to be executed (str) or a list of sql statements to execute

  • conn_id (str) – the connection ID used to connect to the database

  • hook_params (dict | None) – hook parameters

sql[source]
conn_id[source]
hook_params = None[source]
serialize()[source]

Serialize the SQLExecuteQueryTrigger arguments and classpath.

async run()[source]

Run the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

Was this entry helpful?