Created
August 13, 2020 19:58
-
-
Save kai-chu/01c0e28f20c80d0360c2c09216144c6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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