python-3.x - 如何从雪花中的“存储集成”中选择价值?
问题描述
我通过执行以下命令创建了存储集成
create or replace storage integration stager
type = external_stage
storage_provider = s3
enabled = true
storage_aws_role_arn = 'arn:aws:iam::24545426:role/test'
storage_allowed_locations = ('s3://testb/')
之后我执行了DESC INTEGRATION stager
我得到了像
现在我想要选择STORAGE_AWS_EXTERNAL_ID
和property value
。stager
如何选择 STORAGE_AWS_EXTERNAL_ID
和property value
使用查询或python?
解决方案
您可以使用 RESULT_SCAN 函数来处理另一个查询的结果(使用 SQL):
https://docs.snowflake.com/en/sql-reference/functions/result_scan.html
对于蟒蛇:
import snowflake.connector
ctx = snowflake.connector.connect(
...
)
cs = ctx.cursor()
try:
sql = "DESC INTEGRATION stager"
cs.execute( sql )
for (c_property, c_type, c_value, c_default) in cs:
if c_property == "STORAGE_AWS_EXTERNAL_ID":
print('{0}, {1}'.format(c_property, c_value))
finally:
cs.close()
这是上述 Python 脚本的结果:
STORAGE_AWS_EXTERNAL_ID, WX65722_SFCRole=2_GpY+ZF0b41Nu3d2ZDFYPfCUbBxk=
推荐阅读
- django - Django Forms: How to create a simple dropdown list in a form using values from an existing model
- php - Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1109 Unknown table 'users' in information_schema
- c++ - std::sort 在共享指针向量上
- .net - 如何在 Azure 逻辑应用中使用 Liquid 模板添加时间?
- vue.js - 背景属性在 Vue.js 中不起作用
- aws-lambda - How to access aws resources created in other account
- python - 收到错误:行包含空值,不确定原因
- elasticsearch - Monitor kubernetes ingress resources with elastic heartbeat
- python - 为python中的一个句子选择一个主题
- c# - 如何使用 UWP 的 Frame 知道导航转换何时结束?