airflow.providers.standard.operators.generic_transfer

模組內容

類別

GenericTransfer

將資料從一個連線移動到另一個連線。

class airflow.providers.standard.operators.generic_transfer.GenericTransfer(*, sql, destination_table, source_conn_id, source_hook_params=None, destination_conn_id, destination_hook_params=None, preoperator=None, insert_args=None, **kwargs)[原始碼]

基底類別: airflow.models.BaseOperator

將資料從一個連線移動到另一個連線。

假設它們都在各自的 Hook 中提供所需的方法。來源 Hook 需要公開 get_records 方法,而目的地 Hook 需要公開 insert_rows 方法。

這適用於適合放入記憶體的小型資料集。

參數
  • sql (str) – 要對來源資料庫執行的 SQL 查詢。(可使用 Jinja 模板)

  • destination_table (str) – 目標表格。(可使用 Jinja 模板)

  • source_conn_id (str) – 來源連線。(可使用 Jinja 模板)

  • destination_conn_id (str) – 目的地連線。(可使用 Jinja 模板)

  • preoperator (str | list[str] | None) – 在載入資料之前執行的 SQL 陳述式或陳述式列表。(可使用 Jinja 模板)

  • insert_args (dict | None) – insert_rows 方法的額外參數。

template_fields: collections.abc.Sequence[str] = ('source_conn_id', 'destination_conn_id', 'sql', 'destination_table', 'preoperator', 'insert_args')[原始碼]
template_ext: collections.abc.Sequence[str] = ('.sql', '.hql')[原始碼]
template_fields_renderers[原始碼]
ui_color = '#b0f07c'[原始碼]
classmethod get_hook(conn_id, hook_params=None)[原始碼]

傳回此連線 ID 的預設 Hook。

參數
  • conn_id (str) – 連線 ID

  • hook_params (dict | None) – Hook 參數

傳回

此連線的預設 Hook

傳回類型

airflow.hooks.base.BaseHook

execute(context)[原始碼]

在建立運算子時衍生。

Context 是與呈現 Jinja 模板時相同的字典。

請參閱 get_template_context 以取得更多上下文。

此條目是否有幫助?