Airflow: how to delete a DAG?

前端 未结 16 1021
感动是毒
感动是毒 2020-11-28 23:45

I have started the Airflow webserver and scheduled some dags. I can see the dags on web GUI.

How can I delete a particular DAG from being run and shown in web GUI? I

16条回答
  •  余生分开走
    2020-11-29 00:17

    This is my adapted code using PostgresHook with the default connection_id.

    import sys
    from airflow.hooks.postgres_hook import PostgresHook
    
    dag_input = sys.argv[1]
    hook=PostgresHook( postgres_conn_id= "airflow_db")
    
    for t in ["xcom", "task_instance", "sla_miss", "log", "job", "dag_run", "dag" ]:
        sql="delete from {} where dag_id='{}'".format(t, dag_input)
        hook.run(sql, True)
    

提交回复
热议问题