在Airflow中使用Insert_Rows DB挂钩的简单示例

时间:2019-06-22 00:36:05

标签: airflow

有人可以通过简单示例帮助我在Airflow中使用Insert_Rows DB挂钩吗? 我有一个插入表的要求。 我该怎么做并提交数据库。 从气流开始,所以简单的示例将有助于更好地理解。

1 个答案:

答案 0 :(得分:0)

有很多方法。这取决于您偏爱的模式。

根据您的描述,我认为最简单的方法是使用dboperator + SQL。它需要强大的数据库管理经验和一定的气流经验。例如:

process_order_fact = PostgresOperatorWithTemplatedParams(
    task_id='process_order_fact',
    postgres_conn_id='postgres_dwh',
    sql='process_order_fact.sql',
    parameters={"window_start_date": "{{ ds }}", "window_end_date": "{{ tomorrow_ds }}"},
    dag=dag,
    pool='postgres_dwh'

以上代码是从https://gtoonstra.github.io/etl-with-airflow/etlexample.html复制的

祝你好运。

相关问题