在气流中运行存储过程 [英] Run Stored Procedure in Airflow

查看:108
本文介绍了在气流中运行存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Airflow中运行存储过程.简而言之,我导入了mssql运算符,并尝试执行以下操作:

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')

成功完成此任务.但是,任务甚至没有执行.因为我没有从系统中得到任何错误,所以我也无法识别该错误.为了确定它是否到达了我的Microsoft sql服务器,我检查了数据配置文件,发现服务器似乎获得了该命令,但未执行该命令.确实,我可以在数据分析工具中看到sql命令.

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?

推荐答案

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

这篇关于在气流中运行存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆