问题:当我使用连接器调用雪花中的存储过程时,会引发一个异常,其内容是:“名称‘EmptyArrowIterator’未定义”。
我的目标:使用雪花的Python连接器调用存储过程并将返回值保存到变量。
我的代码:
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)谢谢你的帮助!
发布于 2020-05-20 21:56:24
我添加了call_logging_sproc.fetchmany(1),错误就消失了。
https://stackoverflow.com/questions/61900742
复制相似问题