Skip to content

Instantly share code, notes, and snippets.

@kai-chu
Created August 13, 2020 19:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kai-chu/01c0e28f20c80d0360c2c09216144c6a to your computer and use it in GitHub Desktop.
Save kai-chu/01c0e28f20c80d0360c2c09216144c6a to your computer and use it in GitHub Desktop.
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.hooks.base_hook import BaseHook
from airflow.utils.dates import days_ago
default_args = {
'start_date': days_ago(2)
}
dag = DAG('test-connection-hook', default_args = default_args, description='Test connection details', schedule_interval='@once')
def _operator_call_get_details_from_conn(**op_kwargs):
conn = BaseHook.get_connection('test_connection_name')
print("{}, {}".format(conn.id, conn.password))
with dag:
getDetailsFromConnection = PythonOperator(task_id = 'getDetailsFromConnection', python_callable = _operator_call_get_details_from_conn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment