Snowflake sqlalchemy python无法连接,因为公司网络的虚拟机getaddrinfo失败



我需要读取和写入一些数据到雪花数据库。我有凭据,在我的本地电脑上一切都很好。但是在公司的虚拟机中,我做这个,我得到这个我认为这是一个代理问题,但我不知道该怎么做和如何解决。在虚拟机上,我可以访问雪花的url完美无瑕,一切工作在谷歌浏览器为例。但是为什么这个请求不能在python中工作??为什么?我怎样才能修好它?请帮忙:

error message `Traceback (most recent call last):
File "snowflakeconnectorvendoredurllib3connection.py", line 174, in _new_conn
File "snowflakeconnectorvendoredurllib3utilconnection.py", line 72, in create_connection
File "socket.py", line 954, in getaddrinfo
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 703, in urlopen
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 386, in _make_request
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 1042, in _validate_conn
File "snowflakeconnectorvendoredurllib3connection.py", line 358, in connect
File "snowflakeconnectorvendoredurllib3connection.py", line 186, in _new_conn
snowflake.connector.vendored.urllib3.exceptions.NewConnectionError: <snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002073B6C6C10>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflakeconnectorvendoredrequestsadapters.py", line 489, in send
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 815, in urlopen
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 787, in urlopen
File "snowflakeconnectorvendoredurllib3utilretry.py", line 592, in increment
snowflake.connector.vendored.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=d395ab35-5f2a-4fb2-a83b-48458979f2c9&databaseName=project_database&schemaName=project_schema&request_guid=19c8e3a5-33ad-48c2-8124-fc69a1fa2af9 (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002073B6C6C10>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflakeconnectornetwork.py", line 1018, in _request_exec
File "snowflakeconnectorvendoredrequestssessions.py", line 587, in request
File "snowflakeconnectorvendoredrequestssessions.py", line 701, in send
File "snowflakeconnectorvendoredrequestsadapters.py", line 565, in send
snowflake.connector.vendored.requests.exceptions.ConnectionError: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=d395ab35-5f2a-4fb2-a83b-48458979f2c9&databaseName=project_database&schemaName=project_schema&request_guid=19c8e3a5-33ad-48c2-8124-fc69a1fa2af9 (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002073B6C6C10>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflakeconnectorconnection.py", line 1072, in __authenticate
File "snowflakeconnectorauth.py", line 257, in authenticate
File "snowflakeconnectornetwork.py", line 704, in _post_request
File "snowflakeconnectornetwork.py", line 794, in fetch
File "snowflakeconnectornetwork.py", line 917, in _request_exec_wrapper
File "snowflakeconnectornetwork.py", line 837, in _request_exec_wrapper
File "snowflakeconnectornetwork.py", line 1095, in _request_exec
snowflake.connector.errors.OperationalError: 251011: 251011: ConnectionTimeout occurred. Will be handled by authenticator
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "sqlalchemyenginebase.py", line 3361, in _wrap_pool_connect
File "sqlalchemypoolbase.py", line 327, in connect
File "sqlalchemypoolbase.py", line 894, in _checkout
File "sqlalchemypoolbase.py", line 493, in checkout
File "sqlalchemypoolimpl.py", line 146, in _do_get
File "sqlalchemyutillanghelpers.py", line 70, in __exit__
File "sqlalchemyutilcompat.py", line 211, in raise_
File "sqlalchemypoolimpl.py", line 143, in _do_get
File "sqlalchemypoolbase.py", line 273, in _create_connection
File "sqlalchemypoolbase.py", line 388, in __init__
File "sqlalchemypoolbase.py", line 691, in __connect
File "sqlalchemyutillanghelpers.py", line 70, in __exit__
File "sqlalchemyutilcompat.py", line 211, in raise_
File "sqlalchemypoolbase.py", line 686, in __connect
File "sqlalchemyenginecreate.py", line 578, in connect
File "sqlalchemyenginedefault.py", line 598, in connect
File "snowflakeconnector__init__.py", line 51, in Connect
File "snowflakeconnectorconnection.py", line 297, in __init__
File "snowflakeconnectorconnection.py", line 550, in connect
File "snowflakeconnectorconnection.py", line 789, in __open_connection
File "snowflakeconnectorconnection.py", line 1052, in _authenticate
File "snowflakeconnectorconnection.py", line 1117, in __authenticate
File "snowflakeconnectorconnection.py", line 1094, in __authenticate
File "snowflakeconnectorauth_by_plugin.py", line 117, in handle_timeout
snowflake.connector.errors.OperationalError: 250001: 250001: Could not connect to Snowflake backend after 0 attempt(s).Aborting
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "srcsnowflakesqlalchemy.py", line 19, in <module>
File "sqlalchemyenginebase.py", line 3315, in connect
File "sqlalchemyenginebase.py", line 96, in __init__
File "sqlalchemyenginebase.py", line 3394, in raw_connection
File "sqlalchemyenginebase.py", line 3364, in _wrap_pool_connect
File "sqlalchemyenginebase.py", line 2198, in _handle_dbapi_exception_noconnection
File "sqlalchemyutilcompat.py", line 211, in raise_
File "sqlalchemyenginebase.py", line 3361, in _wrap_pool_connect
File "sqlalchemypoolbase.py", line 327, in connect
File "sqlalchemypoolbase.py", line 894, in _checkout
File "sqlalchemypoolbase.py", line 493, in checkout
File "sqlalchemypoolimpl.py", line 146, in _do_get
File "sqlalchemyutillanghelpers.py", line 70, in __exit__
File "sqlalchemyutilcompat.py", line 211, in raise_
File "sqlalchemypoolimpl.py", line 143, in _do_get
File "sqlalchemypoolbase.py", line 273, in _create_connection
File "sqlalchemypoolbase.py", line 388, in __init__
File "sqlalchemypoolbase.py", line 691, in __connect
File "sqlalchemyutillanghelpers.py", line 70, in __exit__
File "sqlalchemyutilcompat.py", line 211, in raise_
File "sqlalchemypoolbase.py", line 686, in __connect
File "sqlalchemyenginecreate.py", line 578, in connect
File "sqlalchemyenginedefault.py", line 598, in connect
File "snowflakeconnector__init__.py", line 51, in Connect
File "snowflakeconnectorconnection.py", line 297, in __init__
File "snowflakeconnectorconnection.py", line 550, in connect
File "snowflakeconnectorconnection.py", line 789, in __open_connection
File "snowflakeconnectorconnection.py", line 1052, in _authenticate
File "snowflakeconnectorconnection.py", line 1117, in __authenticate
File "snowflakeconnectorconnection.py", line 1094, in __authenticate
File "snowflakeconnectorauth_by_plugin.py", line 117, in handle_timeout
sqlalchemy.exc.OperationalError: (snowflake.connector.errors.OperationalError) 250001: 250001: Could not connect to Snowflake backend after 0 attempt(s).Aborting
(Background on this error at: https://sqlalche.me/e/14/e3q8)
[44952] Failed to execute script 'snowflakesqlalchemy' due to unhandled exception!`

I also printed these logs:
`2023-01-10 11:17:18,250 - MainThread connection.py:275 - __init__() - INFO - Snowflake Connector for Python Version: 2.8.3, Python Version: 3.9.13, Platform: Windows-10-10.0.17763-SP0
2023-01-10 11:17:18,250 - MainThread connection.py:520 - connect() - DEBUG - connect
2023-01-10 11:17:18,250 - MainThread connection.py:810 - __config() - DEBUG - __config
2023-01-10 11:17:18,250 - MainThread connection.py:934 - __config() - INFO - This connection is in OCSP Fail Open Mode. TLS Certificates would be checked for validity and revocation status. Any other Certificate Revocation related exceptions or OCSP Responder failures would be disregarded in favor of connectivity.
2023-01-10 11:17:18,251 - MainThread connection.py:952 - __config() - INFO - Setting use_openssl_only mode to False
2023-01-10 11:17:18,251 - MainThread converter.py:145 - __init__() - DEBUG - use_numpy: False
2023-01-10 11:17:18,251 - MainThread converter_issue23517.py:27 - __init__() - DEBUG - initialized
2023-01-10 11:17:18,251 - MainThread connection.py:713 - __open_connection() - DEBUG - REST API object was created: kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:18,252 - MainThread auth.py:170 - authenticate() - DEBUG - authenticate
2023-01-10 11:17:18,252 - MainThread auth.py:200 - authenticate() - DEBUG - assertion content: *********
2023-01-10 11:17:18,252 - MainThread auth.py:203 - authenticate() - DEBUG - account=kzhwbsi-gb82213, user=karlpd4c, database=project_database, schema=project_schema, warehouse=None, role=None, request_id=10256208-cea8-4269-a480-820a1c55e4a3
2023-01-10 11:17:18,252 - MainThread auth.py:236 - authenticate() - DEBUG - body['data']: {'CLIENT_APP_ID': 'PythonConnector', 'CLIENT_APP_VERSION': '2.8.3', 'SVN_REVISION': None, 'ACCOUNT_NAME': 'kzhwbsi-gb82213', 'LOGIN_NAME': 'karlpd4c', 'CLIENT_ENVIRONMENT': {'APPLICATION': 'PythonConnector', 'OS': 'Windows', 'OS_VERSION': 'Windows-10-10.0.17763-SP0', 'PYTHON_VERSION': '3.9.13', 'PYTHON_RUNTIME': 'CPython', 'PYTHON_COMPILER': 'MSC v.1929 64 bit (AMD64)', 'OCSP_MODE': 'FAIL_OPEN', 'TRACING': 10, 'LOGIN_TIMEOUT': 120, 'NETWORK_TIMEOUT': None}, 'SESSION_PARAMETERS': {'AUTOCOMMIT': False, 'CLIENT_PREFETCH_THREADS': 4}}
2023-01-10 11:17:18,252 - MainThread auth.py:254 - authenticate() - DEBUG - Timeout set to 120
2023-01-10 11:17:18,253 - MainThread retry.py:351 - from_int() - DEBUG - Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
2023-01-10 11:17:18,253 - MainThread retry.py:351 - from_int() - DEBUG - Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
2023-01-10 11:17:18,253 - MainThread network.py:1147 - _use_requests_session() - DEBUG - Session status for SessionPool 'kzhwbsi-gb82213.snowflakecomputing.com', SessionPool 1/1 active sessions
2023-01-10 11:17:18,253 - MainThread network.py:827 - _request_exec_wrapper() - DEBUG - remaining request timeout: 120, retry cnt: 1
2023-01-10 11:17:18,254 - MainThread network.py:808 - add_request_guid() - DEBUG - Request guid: 3bcec6fe-8f7d-4c05-9203-626636c975ea
2023-01-10 11:17:18,254 - MainThread network.py:1006 - _request_exec() - DEBUG - socket timeout: 60
2023-01-10 11:17:18,257 - MainThread connectionpool.py:1003 - _new_conn() - DEBUG - Starting new HTTPS connection (1): kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:19,295 - MainThread retry.py:594 - increment() - DEBUG - Incremented Retry for (url='/session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
2023-01-10 11:17:19,295 - MainThread connectionpool.py:812 - urlopen() - WARNING - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9A30>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea
2023-01-10 11:17:19,296 - MainThread connectionpool.py:1003 - _new_conn() - DEBUG - Starting new HTTPS connection (2): kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:19,297 - MainThread network.py:1090 - _request_exec() - DEBUG - Hit a timeout error while logging in. Will be handled by authenticator. Ignore the following. Error stack: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
Traceback (most recent call last):
File "snowflakeconnectorvendoredurllib3connection.py", line 174, in _new_conn
File "snowflakeconnectorvendoredurllib3utilconnection.py", line 72, in create_connection
File "socket.py", line 954, in getaddrinfo
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 703, in urlopen
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 386, in _make_request
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 1042, in _validate_conn
File "snowflakeconnectorvendoredurllib3connection.py", line 358, in connect
File "snowflakeconnectorvendoredurllib3connection.py", line 186, in _new_conn
snowflake.connector.vendored.urllib3.exceptions.NewConnectionError: <snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflakeconnectorvendoredrequestsadapters.py", line 489, in send
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 815, in urlopen
File "snowflakeconnectorvendoredurllib3connectionpool.py", line 787, in urlopen
File "snowflakeconnectorvendoredurllib3utilretry.py", line 592, in increment
snowflake.connector.vendored.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflakeconnectornetwork.py", line 1018, in _request_exec
File "snowflakeconnectorvendoredrequestssessions.py", line 587, in request
File "snowflakeconnectorvendoredrequestssessions.py", line 701, in send
File "snowflakeconnectorvendoredrequestsadapters.py", line 565, in send
snowflake.connector.vendored.requests.exceptions.ConnectionError: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
2023-01-10 11:17:19,305 - MainThread network.py:1152 - _use_requests_session() - DEBUG - Session status for SessionPool 'kzhwbsi-gb82213.snowflakecomputing.com', SessionPool 0/1 active sessions
2023-01-10 11:17:19,305 - MainThread connection.py:1087 - __authenticate() - DEBUG - Operational Error raised at authenticationfor authenticator: AuthByDefault
2023-01-10 11:17:19,305 - MainThread auth_by_plugin.py:114 - handle_timeout() - DEBUG - Default timeout handler invoked for authenticator
2023-01-10 11:17:19,305 - MainThread auth_by_plugin.py:123 - handle_timeout() - DEBUG - Hit connection timeout, attempt number 0. Will retry in a bit...
2023-01-10 11:17:19,305 - MainThread auth_by_plugin.py:56 - next_sleep_duration() - DEBUG - Sleeping for 2 seconds
2023-01-10 11:17:21,306 - MainThread auth.py:170 - authenticate() - DEBUG - authenticate
2023-01-10 11:17:21,306 - MainThread auth.py:200 - authenticate() - DEBUG - assertion content: *********
2023-01-10 11:17:21,306 - MainThread auth.py:203 - authenticate() - DEBUG - account=kzhwbsi-gb82213, user=karlpd4c, database=project_database, schema=project_schema, warehouse=None, role=None, request_id=f8210470-5260-46c4-b7a5-1458f5dc318a
2023-01-10 11:17:21,306 - MainThread auth.py:236 - authenticate() - DEBUG - body['data']: {'CLIENT_APP_ID': 'PythonConnector', 'CLIENT_APP_VERSION': '2.8.3', 'SVN_REVISION': None, 'ACCOUNT_NAME': 'kzhwbsi-gb82213', 'LOGIN_NAME': 'karlpd4c', 'CLIENT_ENVIRONMENT': {'APPLICATION': 'PythonConnector', 'OS': 'Windows', 'OS_VERSION': 'Windows-10-10.0.17763-SP0', 'PYTHON_VERSION': '3.9.13', 'PYTHON_RUNTIME': 'CPython', 'PYTHON_COMPILER': 'MSC v.1929 64 bit (AMD64)', 'OCSP_MODE': 'FAIL_OPEN', 'TRACING': 10, 'LOGIN_TIMEOUT': 120, 'NETWORK_TIMEOUT': None}, 'SESSION_PARAMETERS': {'AUTOCOMMIT': False, 'CLIENT_PREFETCH_THREADS': 4}}
2023-01-10 11:17:21,307 - MainThread auth.py:254 - authenticate() - DEBUG - Timeout set to 120
2023-01-10 11:17:21,307 - MainThread network.py:1147 - _use_requests_session() - DEBUG - Session status for SessionPool 'kzhwbsi-gb82213.snowflakecomputing.com', SessionPool 1/1 active sessions
2023-01-10 11:17:21,307 - MainThread network.py:827 - _request_exec_wrapper() - DEBUG - remaining request timeout: 120, retry cnt: 1
2023-01-10 11:17:21,307 - MainThread network.py:808 - add_request_guid() - DEBUG - Request guid: dbe010e1-6776-46ed-bc5a-9979d617bee4
2023-01-10 11:17:21,307 - MainThread network.py:1006 - _request_exec() - DEBUG - socket timeout: 60
2023-01-10 11:17:21,311 - MainThread connectionpool.py:1003 - _new_conn() - DEBUG - Starting new HTTPS connection (3): kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:21,312 - MainThread retry.py:594 - increment() - DEBUG - Incremented Retry for (url='/session/v1/login-request?request_id=f8210470-5260-46c4-b7a5-1458f5dc318a&databaseName=project_database&schemaName=project_schema&request_guid=dbe010e1-6776-46ed-bc5a-9979d617bee4'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
2023-01-10 11:17:21,312 - MainThread connectionpool.py:812 - urlopen() - WARNING - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002999382B790>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /session/v1/login-request?request_id=f8210470-5260-46c4-b7a5-1458f5dc318a&databaseName=project_database&schemaName=project_schema&request_guid=dbe010e1-6776-46ed-bc5a-9979d617bee4
2023-01-10 11:17:21,312 - MainThread connectionpool.py:1003 - _new_conn() - DEBUG - Starting new HTTPS connection (4): kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:21,314 - MainThread network.py:1090 - _request_exec() - DEBUG - Hit a timeout error while logging in. Will be handled by authenticator. Ignore the following. Error stack: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=f8210470-5260-46c4-b7a5-1458f5dc318a&databaseName=project_database&schemaName=project_schema&request_guid=dbe010e1-6776-46ed-bc5a-9979d617bee4 (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002999382BA00>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
Traceback (most recent call last):
File "snowflakeconnectorvendoredurllib3connection.py", line 174, in _new_conn
File "snowflakeconnectorvendoredurllib3utilconnection.py", line 72, in create_connection
File "socket.py", line 954, in getaddrinfo
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
...
这是我的python代码:
#!/usr/bin/env python
from snowflake.sqlalchemy import URL
from sqlalchemy import create_engine
import pandas as pd
import logging
import os
engine = create_engine('snowflake://user:password@myaccount(e.g.asdfhjk-jh45567)/project_database/project_schema')
os.environ['NO_PROXY'] = 'snowflakecomputing.com'
path = input('logpath:n')
for logger_name in ['snowflake','botocore']:
logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG)
ch = logging.FileHandler(path+'python_connector.log')
ch.setLevel(logging.DEBUG)
ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
logger.addHandler(ch)
try:

connection = engine.connect()
sql = "SELECT * FROM project_comments"
df = pd.read_sql_query(sql,connection)
print(df)
df.to_csv("./snowflakedata.csv",index=False)
finally:
engine.dispose()
connection.close()

除了使用sqlalchemy之外,我还尝试了snowflake连接器:

import pandas as pd
import snowflake.connector
import sys
import os
us = input("user: n")
pw = input("password: n")
acc = input("account: n")
cnn = snowflake.connector.connect(
user=us,
password=pw,
account=acc,

)
cs = cnn.cursor()
wh = input("warehouse: n")
db = input("database: n")
schema = input("schema: n")
table = input("table: n")
path = input("output directory: n").replace("\", "/")
try:
sql = "USE WAREHOUSE " + wh
cs.execute(sql)
sql = "USE DATABASE "+ db
cs.execute(sql)
sql = "USE SCHEMA " + schema
cs.execute(sql)
sql = "SELECT * FROM " + table
df = pd.read_sql_query(sql,cnn)
print(df)
df.to_csv(path + "snowflakedata.csv",index=False)
input("snowflake has been read, press any key to close")
finally:
cs.close()
cnn.close()

出现同样的问题。在本地pc上工作正常,在本地网络中的虚拟机上不工作。我试图在Windows中禁用代理:

set NO_PROXY=snowflakecomputing.com

我需要雪花db的ip吗?我怎么得到它?在sqlalchemy中的dns配置是否有问题?我怎么修理它?我是否需要另一个连接器或数据库引擎?

我找到了答案:如果您使用的是协作代理,则需要在环境变量中将代理配置为新变量,然后添加以下两个:

HTTP_PROXYhttp://companyuser:companypw@proxy.companydomain.companyname.com:8080和

HTTPS_PROXYhttp://companyuser: companypw@proxy.companydomain.companyname.com: 8080

。然后,您还需要在应用程序级别配置这些http和https代理,这意味着在开始的python程序中:

os.environ["http_proxy"] = "http://companyuser:companypw@proxy.companydomain.companyname.com:8080"
os.environ["https_proxy"] ="http://companyuser:companypw@proxy.companydomain.companyname.com:8080"

在本例中,companyuser是我的Windows机器上的用户。

最新更新