airflow.operators.generic_transfer

模組內容

類別

GenericTransfer

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

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

Bases: airflow.models.BaseOperator

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

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

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

參數
  • sql (str) – 要對來源資料庫執行的 SQL 查詢。(樣板化)

  • destination_table (str) – 目標表格。(樣板化)

  • source_conn_id (str) – 來源連線

  • destination_conn_id (str) – 目的地連線

  • preoperator (str | list[str] | None) – 在載入資料之前要執行的 sql 語句或語句列表。(樣板化)

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

template_fields: Sequence[str] = ('sql', 'destination_table', 'preoperator')[原始碼]
template_ext: Sequence[str] = ('.sql', '.hql')[原始碼]
template_fields_renderers[原始碼]
ui_color = '#b0f07c'[原始碼]
execute(context)[原始碼]

在建立 operator 時衍生。

Context 是與呈現 jinja 範本時使用的相同字典。

請參閱 get_template_context 以獲得更多 context。

這篇文章有幫助嗎?