Python 3.8雪花连接错误:Snowflake.connector.errors.OperationalError:250003:250003

2024-09-28 03:13:04 发布

您现在位置:Python中文网/ 问答频道 /正文

Failed to get the response. Hanging? method: post, url: https://ABC.us-east-2.aws.snowflakecomputing.com:443/session/v1/login-request?request_id=efabf1c7-7fb6-48cb-a50e-256967e3de45&databaseName=DATAVAULT&schemaName=STAGE&warehouse=DATAVAULT&roleName=TEST_Admin&request_guid=c99547cd-ceeb-4280-845b-f2de7be76755

在Windows Python 3.8上获取连接错误

连接参数

{
    "user" : "TestUser1",
    "password" : "XXXX",
    "account" : "ABC.us-east-2.aws",
    "warehouse" : "DATAVAULT",
    "database" : "DATAVAULT",
    "schema" : "STAGE",
    "Role" : "Test_role"
}

还尝试将帐户名命名为“ABC”、“ABC.aws”,但不起作用

代码:

    import snowflake.connector as snow

    conn = snow.connect(user=self.user,
      password= self.password,
      account= self.account,
      warehouse=self.warehouse,
          database=self.database,
      schema=self.schema,
      role=self.role
      )
    cur = conn.cursor()

同样的代码在Linux上运行良好,但在Windows版本的Python上则不行。 添加了代理,如下所示,但没有帮助

os.environ['HTTP_PROXY'] = "http://http-proxy.company.com:80"
os.environ['HTTPS_PROXY'] = "https://http-proxy.company.com:443"

===================================== 使用炼金术

import os 

os.environ['HTTP_PROXY'] = "http://http-proxy.xxx.com:80"
os.environ['HTTPS_PROXY'] = "https://https-proxy.xxx.com:443"

from sqlalchemy import create_engine
from snowflake.sqlalchemy import URL
import os
import sys



url = URL(
    account = 'xxxx.us-east-2.aws',
    user = 'TestUser1',
    database = 'DATAVAULT' ,
    schema = 'STAGE',
    warehouse= 'DATAVAULT',
    role = 'DV_Admin',
    password='xxxx', # note my passsword has a '@' in it 
)
print(os.environ['HTTP_PROXY'])
print(os.environ['HTTPS_PROXY'])


engine = create_engine(url)
print(engine)
results = engine.execute('select current_version()').fetchone()
sys.exit()
try:
    results = engine.execute('select current_version()').fetchone()
    assert results is not None
finally:
    engine.dispose()

Tags: httpsimportselfcomawshttposenviron

热门问题