如何将绑定变量传递给 python 的 snowflake 中的 copy into 语句

How to pass the bind variable to the copy into statement in snowflake from python

.执行("copy into tmp_cdp_score_feature from @cdp_json_acpt/data/1 file_format = (type=json)"

因为最后一个值会像 data/2、data/3 一样从 1 到 100 不等,所以我需要作为变量传递。

类似于

.执行("copy into tmp_cdp_score_feature from @cdp_json_acpt/data/(%s) file_format = (type=json),(2)"

我认为您可能只是在 "something like" 中的错误位置使用了双引号。绑定变量的格式也是一个参数选项

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

参考文档: https://docs.snowflake.com/en/user-guide/python-connector-api.html

从@stg_json_acpt/"'%s'"复制到tmp_stg file_format = (type=json), Force=True" %(des1)

des1=s3目标文件的路径 工作正常,经过测试