在气流中运行存储过程

编程入门 行业动态 更新时间:2024-10-22 15:24:38
本文介绍了在气流中运行存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试在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

更多推荐

在气流中运行存储过程

本文发布于:2023-11-23 19:47:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622671.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:气流   存储过程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!