Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从python向snowflake中的copy into语句传递bind变量_Python_Snowflake Cloud Data Platform - Fatal编程技术网

如何从python向snowflake中的copy into语句传递bind变量

如何从python向snowflake中的copy into语句传递bind变量,python,snowflake-cloud-data-platform,Python,Snowflake Cloud Data Platform,.execute(“从@cdp_json_acpt/data/1文件格式=(type=json)复制到tmp_cdp_score_功能中”) 由于最后一个值将在1到100之间变化,如data/2、data/3,因此我需要作为变量传递 差不多 .execute(“从@cdp_json_acpt/data/(%s)file_format=(type=json),(2)复制到tmp_cdp_score_功能中)”我想您可能只是在“类似”中的双引号放错了位置。绑定变量的格式也是一个参数选项 format

.execute(“从@cdp_json_acpt/data/1文件格式=(type=json)复制到tmp_cdp_score_功能中”)

由于最后一个值将在1到100之间变化,如data/2、data/3,因此我需要作为变量传递

差不多


.execute(“从@cdp_json_acpt/data/(%s)file_format=(type=json),(2)复制到tmp_cdp_score_功能中)”

我想您可能只是在“类似”中的双引号放错了位置。绑定变量的格式也是一个参数选项

format: .execute("... WHERE my_column = %s", (value,)) 
pyformat: .execute("... WHERE my_column = %(name)s", {"name": value}) 
qmark: .execute("... WHERE my_column = ?", (value,)) 
numeric: .execute("... WHERE my_column = :1", (value,))
参考文件:

从@stg\u json\u acpt/“'%s'”文件复制到tmp\u stg中,文件格式=(type=json),Force=True“%(des1)

des1=s3对象文件的路径
它运行良好,经过测试

是的,对于where和insert,我们可以使用单独的双引号,但如何在copy-into语句中使用。您是否收到错误?我认为它也可以工作。执行(“copy-into-tmp\u feature from@json\u acpt/%s file\u format=(type=json)”,(path))值最终传递给%s,但我收到了错误”SQL编译错误:\n语法错误行1位于位置62意外的“output\u 24\u 10.json”“。我会在Snowflake中检查查询历史记录以查看查询的实际内容。听起来您在绑定上的语法不错,但您的COPY-to语句不正确。出于好奇,我找到了解决方法。execute(“,”)看起来如何添加了?执行。(“从@stg_json_acpt/”复制到tmp_stg中“%s”文件格式=(type=json),Force=True“%(des1))