简体   繁体   中英

Error trying to connect to snowflake from python using the AzureAD login

I'm trying to connect to snowflake from Python using AzureAD login with the following code:

import os
os.system('python -m pip install --upgrade pip')
os.system('pip install -r https://raw.githubusercontent.com/snowflakedb/snowflake-connector-python/v2.4.2/tested_requirements/requirements_38.reqs')
os.system('pip install snowflake-connector-python==2.4.2')
os.system('pip install "snowflake-connector-python[secure-local-storage]"')

    ctx = snowflake.connector.connect(
    user='xxxx@mydomain.com',
    password='xxxxx',
    host='<xxxx.east-us-2.azure.snowflakecomputing.com',
    account='xxxx.east-us-2',
    authenticator='externalbrowser',
    warehouse='xxxx'
    )
cs = ctx.cursor()
try:
    cs.execute("SELECT * FROM TABLE")
    rows = cs.fetchall()
    for row in rows:
        print(row)
finally:
    cs.close()
ctx.close()    

But I'm getting this error:

OperationalError: 250003: Failed to execute request: HTTPSConnectionPool(host='%xxxxx.east-us-2.azure.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/authenticator-request?request_guid=3ba50eab-2575-4ceb-a658-922c51d94a1b (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000001E1139BA9D0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

Any idea of what I have to do?

Your account should be like this:

account='xxxx.east-us-2.azure'

You're missing cloud provider at the end of the account name. See the account name examples here:

https://docs.snowflake.com/en/user-guide/python-connector-install.html#step-2-verify-your-installation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM