MssqlHook airflow connection

。_饼干妹妹 提交于 2019-12-02 00:23:45

See the standard examples of Airflow.

https://github.com/gtoonstra/etl-with-airflow/blob/master/examples/mssql-example/dags/mssql_bcp_example.py

E.g.:

t1 = MsSqlImportOperator(task_id='import_data',
                         table_name='test.test',
                         generate_synth_data=generate_synth_data,
                         mssql_conn_id='mssql',
                         dag=dag)

EDIT

hook = MsSqlHook(mssql_conn_id="my_mssql_conn")
hook.run(sql)

You need to provide the connection defined in Connections. Also if using Hooks looking in the respective Operators usually yields some information about usage. This code is from the MSSQLOperator.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!