已成功安装pip install --upgrade snowflake-connector-python
,但是我无法打印雪花版本。不知道可能是什么问题。遵循以下链接中提供的步骤。
import snowflake.connector
# Gets the version
ctx = snowflake.connector.connect(
user='<your_user_name>',
password='<your_password>',
account='<your_account_name>'
)
cs = ctx.cursor()
try:
cs.execute("SELECT current_version()")
one_row = cs.fetchone()
print(one_row[0])
finally:
cs.close()
ctx.close()
Traceback (most recent call last):
File "validate.py", line 7, in <module>
account='abc123'
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/__init__.py", line 32, in Connect
return SnowflakeConnection(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/connection.py", line 147, in __init__
self.connect(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/connection.py", line 355, in connect
self.__open_connection()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/connection.py", line 548, in __open_connection
self.__authenticate(auth_instance)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/connection.py", line 771, in __authenticate
session_parameters=self._session_parameters,
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/auth.py", line 214, in authenticate
socket_timeout=self._rest._connection.login_timeout)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/network.py", line 529, in _post_request
_include_retry_params=_include_retry_params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/network.py", line 618, in fetch
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/network.py", line 695, in _request_exec_wrapper
raise e
ImportError: cannot import name dump_publickey
有人可以帮我吗?
日志:
INFO:snowflake.connector.connection:Snowflake Connector for Python Version: 1.6.11, Python Version: 2.7.14, Platform: Darwin-16.7.0-x86_64-i386-64bit
DEBUG:snowflake.connector.connection:connect
DEBUG:snowflake.connector.connection:__config
DEBUG:snowflake.connector.converter:use_sfbinaryformat: False, use_numpy: False
DEBUG:snowflake.connector.connection:REST API object was created: account_name.snowflakecomputing.com:443, proxy=None:None, proxy_user=None
DEBUG:snowflake.connector.auth:authenticate
DEBUG:snowflake.connector.auth:assertion content: *********
DEBUG:snowflake.connector.auth:account=account_name, user=user_name, database=None, schema=None, warehouse=None, role=None, request_id=29f36950-7763-4cee-ab48-bbe3716ca916
DEBUG:snowflake.connector.auth:body['data']: {u'CLIENT_APP_VERSION': u'1.6.11', u'CLIENT_APP_ID': u'PythonConnector', u'CLIENT_ENVIRONMENT': {u'PYTHON_VERSION': u'2.7.14', u'APPLICATION': u'PythonConnector', u'OS_VERSION': 'Darwin-16.7.0-x86_64-i386-64bit', u'PYTHON_COMPILER': 'GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)', u'OS': 'Darwin', u'PYTHON_RUNTIME': 'CPython'}, u'ACCOUNT_NAME': 'account_name', u'SVN_REVISION': None, u'LOGIN_NAME': 'user_name'}
DEBUG:botocore.vendored.requests.packages.urllib3.util.retry:Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None)
DEBUG:botocore.vendored.requests.packages.urllib3.util.retry:Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None)
DEBUG:snowflake.connector.network:Active requests sessions: 1, idle: 0
DEBUG:snowflake.connector.network:remaining request timeout: 120, retry cnt: 1
DEBUG:snowflake.connector.network:socket timeout: 60
INFO:botocore.vendored.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): account_name.snowflakecomputing.com
DEBUG:snowflake.connector.network:Active requests sessions: 0, idle: 1
调试network.py
后,可以确定在def _request_exec
中,在下面的块中执行URL https://account_name.snowflakecomputing.com:443/session/v1/login-request?request_id=9b1c563d-80a2-4608-af4d-8bc6b955ac70&request_guid=b88aba49-384a-409d-8387-4e4f934927ab
遇到错误
raw_ret = session.request(
method=method,
url=full_url,
proxies=proxies,
headers=headers,
data=input_data,
timeout=socket_timeout,
verify=True,
stream=is_raw_binary,
auth=SnowflakeAuth(token),
)
与api / url-execution(requests,urllib3
)相关的任何模块都可能有问题,只是一个猜测。谁能帮我吗?
答案 0 :(得分:0)
我尝试了代码,对我来说很好用。您是否尝试启用日志记录?如果可以,您可以共享日志吗?另外,请确保您正确设置了帐户详细信息。
只要您没有启用日志记录,就可以通过将以下行添加到python脚本中来启用它:
import logging
logging.basicConfig(
filename='/tmp/snowflake_python_connector.log',
level=logging.DEBUG)