如何从雪花中的 "storage integration" 中 select 取值?

how to select value from "storage integration" in snowflake?

我已经通过执行以下命令创建了存储集成

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

我得到了这样的结果

现在我想要 select STORAGE_AWS_EXTERNAL_IDproperty valuestager .

如何 select STORAGE_AWS_EXTERNAL_IDproperty value 使用查询或 python?

您可以使用 RESULT_SCAN 函数来处理另一个查询的结果(使用 SQL):

https://docs.snowflake.com/en/sql-reference/functions/result_scan.html

https://docs.snowflake.com/en/sql-reference/functions/result_scan.html#examples-using-describe-and-show-commands

对于python:

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=