Skip to content

Instantly share code, notes, and snippets.

@anderser
Created April 11, 2016 19:08
Show Gist options
  • Save anderser/be919a3af147674f39c120939414d5df to your computer and use it in GitHub Desktop.
Save anderser/be919a3af147674f39c120939414d5df to your computer and use it in GitHub Desktop.
Error in Airflow DAG
from __future__ import print_function
from builtins import range
from airflow.operators import PythonOperator, PostgresOperator, DummyOperator
from airflow.models import DAG
from datetime import datetime, timedelta
import time
from pprint import pprint
seven_days_ago = datetime.combine(
datetime.today() - timedelta(7), datetime.min.time())
args = {
'owner': 'airflow',
'start_date': seven_days_ago,
}
dag = DAG(
dag_id='anders_test_dag', default_args=args,
schedule_interval=None)
def hello_world(ds, **kwargs):
print(ds)
return 'Hello World!'
task1 = PythonOperator(
task_id='hello_world',
provide_context=True,
python_callable=hello_world,
dag=dag)
task2 = PostgresOperator(
task_id='postgrestest',
provide_context=True,
autocommit=True,
sql="DELETE * from myschema.mytable",
postgres_conn_id="my-datastore",
dag=dag
)
task2.set_upstream(task1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment