Run Stored Procedure in Airflow

蹲街弑〆低调 提交于 2019-12-08 05:04:32

问题


I try to run my stored procedure in Airflow. Simply, I imported mssql operator and tried to execute following:

sql_command = """ EXEC [spAirflowTest] """
t3 = MsSqlOperator( task_id = 'run_test_proc',
                    mssql_conn_id = 'FIConnection',
                    sql = sql_command,
                    dag = dag,
                    database = 'RDW')

It completes this task as successful. However, task is not even executed. Because I get no error from system, I also cannot identify the error. To identify whether it arrived to my microsoft sql server, I checked with data profiling and it seems like server gets the command but does not execute it. Indeed, I can see sql command in data profiling tool.

When I run command for reading something, like :

select *
from sys.tables

it returns successful, also, with result. How can I solve this problem? Is there anyone who encountered with this issue?


回答1:


sql_command = """ EXEC [spAirflowTest] """
t3 = MsSqlOperator( task_id = 'run_test_proc',
                    mssql_conn_id = 'FIConnection',
                    sql = sql_command,
                    dag = dag,
                    database = 'RDW',
                    autocommit = True)

adding autocommit as above solved the issue



来源:https://stackoverflow.com/questions/55455029/run-stored-procedure-in-airflow

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