snowflake-cloud-data-platform - 使用 Snowflake 的 Python 连接器调用存储过程时,名称“EmptyArrowIterator”未定义错误
问题描述
问题:当我使用 Python 连接器在 Snowflake 中调用存储过程时,会引发异常,内容为:“未定义名称‘EmptyArrowIterator’”。
我的目标:使用 Snowflake 的 Python 连接器调用存储过程并将返回值保存到变量中。
我尝试了什么: 我按照此 Stack Exchange 帖子中的说明进行操作,但未能成功解决错误。
我的代码:
import pandas as pd
#my code is long...a dataframe called credentials is defined elsewhere in my code and is not shown below
def logging_sproc(credentials):
try:
#import snowflake module and binding method
import snowflake.connector
#necesary for passing python variables to statements; note this method is server side
#so there is no concern about SQL injection attacks
snowflake.connector.paramstyle='qmark'
#etl logging variables
etl_name = credentials.iloc[0]['etl_name']
etl_guid = credentials.iloc[0]['etl_guid']
etl_taskname = credentials.iloc[0]['etl_task_name']
etl_record_count = credentials.iloc[0]['record_count']
#snowflake variables
snowflake_warehouse = credentials.iloc[0]['snowflake_warehouse']
snowflake_account = credentials.iloc[0]['snowflake_account']
snowflake_role = credentials.iloc[0]['snowflake_role']
snowflake_username = credentials.iloc[0]['Username']
snowflake_password = credentials.iloc[0]['Password']
snowflake_connection = ''
cs = ''#snowflake connection cursor
call_logging_sproc = ''
#call the logging stored procedure
snowflake_connection = snowflake.connector.connect(
user = snowflake_username,
password = snowflake_password,
account = snowflake_account,
warehouse = snowflake_warehouse,
role = snowflake_role)
cs = snowflake_connection.cursor()
call_logging_sproc = cs.execute("CALL EDW_DEV.LOGGING.LOGGING_SP(?,?,?,?)",(etl_name,etl_guid,etl_taskname,etl_record_count))
except Exception as error:
return error
finally:
snowflake_connection.close()
return call_logging_sproc
logging_sp = logging_sproc(credentials)
谢谢您的帮助!
解决方案
我添加了 call_logging_sproc.fetchmany(1) 并且错误消失了。
推荐阅读
- python - 具有可变数量工人的任务的最佳调度
- asp.net - 将 Web App .Net 4 更新到在 Visual Studio Debug 上运行但不在 IIS 8.5 上运行的 4.7.2
- vba - 如何在VBA中测试阿拉伯语中的单词是阳性还是阴性
- python - 如何拦截在 Python 程序的终端窗口中(且仅在)中按下的键?
- r - 较大数据集分类中的神经网络
- java - Vertx HttpClientRequest 处理程序行为测试
- webpack - 带有 webpack 和 infer-externs 的 Clojurescript 需要具有高级编译的未定义对象
- python - 熊猫if条件来自多列的字符串
- spring-boot - SpringBoot中的rails是否有等效于before_filter的方法?
- php - $_SERVER['DOCUMENT_ROOT'] 的目的是什么