1

我在 for 循环中的脚本路径下运行所有​​ sql 脚本,并将数据复制到雪花中的 @priya_stage 区域,然后使用 GET 命令,我正在以 csv 格式将数据从舞台区域卸载到我的 Unix 路径。但我收到错误。 注意:相同的代码适用于我的 MAC,但不适用于 unix 服务器。

    import logging
    import os
    import snowflake.connector
    from snowflake.connector import DictCursor as dict
    from os import walk
    
    try:
        conn = snowflake.connector.connect(
            account = 'xxx' ,
            user = 'xxx' ,
            password = 'xxx' ,
            database = 'xxx' ,
            schema = 'xxx' ,
            warehouse = 'xxx' ,
            role = 'xxx' ,
        )
    
        conn.cursor().execute('USE WAREHOUSE xxx')
        conn.cursor().execute('USE DATABASE xxx')
        conn.cursor().execute('USE SCHEMA xxx')
    
        take = []
        scripts = '/xxx/apps/xxx/xxx/scripts/snow/scripts/'
        os.chdir('/xxx/apps/xxx/xxx/scripts/snow/scripts/')
    
        for root , dirs , files in walk(scripts):
            for file in files:
                inbound = file[0:-4]
                sql = open(file , 'r').read()
                # file_number = 0
                # file_number += 1
                file_prefix = 'bridg_' + inbound
                file_name = file_prefix
                result_query = conn.cursor(dict).execute(sql)
                query_id = result_query.sfqid
                sql_copy_into = f'''
                copy into @priya_stage/{file_name}
                from (SELECT * FROM TABLE(RESULT_SCAN('{query_id}')))
                DETAILED_OUTPUT = TRUE
                HEADER = TRUE
                SINGLE = FALSE
                OVERWRITE = TRUE
                max_file_size=4900000000'''
                rs_copy_into = conn.cursor(dict).execute(sql_copy_into)
    
                for row_copy in rs_copy_into:
                    file_name_in_stage = row_copy["FILE_NAME"]
                    sql_get_to_local = f"""
                      GET @priya_stage/{file_name_in_stage} file:///xxx/apps/xxx/xxx/inbound/zip_files/{inbound}/"""
                    rs_get_to_local = conn.cursor(dict).execute(sql_get_to_local)
    except snowflake.connector.errors.ProgrammingError as e:
        print('Error {0} ({1}): {2} ({3})'.format(e.errno , e.sqlstate , e.msg , e.sfqid))
    finally:
        conn.cursor().close()
        conn.close()

错误

Traceback (most recent call last):
  File "Generic_local.py", line 52, in <module>
  rs_get_to_local = conn.cursor(dict).execute(sql_get_to_local)
  File "/usr/local/lib64/python3.6/site-packages/snowflake/connector/cursor.py", line 
  746, in execute
  sf_file_transfer_agent.execute()
  File "/usr/local/lib64/python3.6/site- 
  packages/snowflake/connector/file_transfer_agent.py", line 379, in execute
  self._transfer_accelerate_config()
  File "/usr/local/lib64/python3.6/site- 
  packages/snowflake/connector/file_transfer_agent.py", line 671, in 
  _transfer_accelerate_config
  self._use_accelerate_endpoint = client.transfer_accelerate_config()
  File "/usr/local/lib64/python3.6/site- 
  packages/snowflake/connector/s3_storage_client.py", line 572, in 
  transfer_accelerate_config
  url=url, verb="GET", retry_id=retry_id, query_parts=dict(query_parts)
  File "/usr/local/lib64/python3.6/site- 
  packages/snowflake/connector/s3_storage_client.py", line 353, in _. 
  send_request_with_authentication_and_retry
  verb, generate_authenticated_url_and_args_v4, retry_id
  File "/usr/local/lib64/python3.6/site- 
  packages/snowflake/connector/storage_client.py", line 313, in 
  _send_request_with_retry
  f"{verb} with url {url} failed for exceeding maximum retries."
  snowflake.connector.errors.RequestExceedMaxRetryError: GET with url b'https://xxx- 
  xxxxx-xxx-x-customer-stage.xx.amazonaws.com/https://xxx-xxxxx-xxx-x-customer- 
  stage.xx.amazonaws.com/?accelerate' failed for exceeding maximum retries.

此链接将我重定向到错误消息。https://xxx- xxxxx-xxx-x-customer-stage.xx.amazonaws.com/https://xxx-xxxxx-xxx-x-customer-stage.xx.amazonaws.com/?accelerate

访问被拒绝错误:

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>1X1Z8G0BTX8BAHXK</RequestId>
<HostId>QqdCqaSK7ogAEq3sNWaQVZVXUGaqZnPv78FiflvVzkF6nSYXTSKu3iSiYlUOU0ka+0IMzErwGC4=</HostId>
</Error>
4

0 回答 0