无法使用雪花连接器python v1.9建立连接

时间:2019-10-08 16:38:36

标签: python snowflake-data-warehouse

(代表客户询问以下问题)

............

由于所有依赖项的大小,雪花连接器python必须切换到v1.9(总大小为106Mb),而现在我无法建立连接,因此v2.0也无法正常运行。唯一可以使用的版本是v2.0.1,但与v1.9相比,它的容量巨大(总大小为320Mb)。

Traceback (most recent call last):

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ocsp_snowflake.py", line 1131, in validate_by_direct_connection

  self.process_ocsp_response(issuer, cert_id, ocsp_response)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 280, in process_ocsp_response

  tbs_response_data)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 316, in verify_signature

  pubkey = cert.public_key.unwrap().dump()

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/asn1crypto/keys.py", line 1065, in unwrap

  'asn1crypto.keys.PublicKeyInfo().unwrap() has been removed, '

asn1crypto._errors.APIException: asn1crypto.keys.PublicKeyInfo().unwrap() has been removed, please use oscrypto.asymmetric.PublicKey().unwrap() instead



During handling of the above exception, another exception occurred:

Traceback (most recent call last):

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/network.py", line 790, in _request_exec

  auth=SnowflakeAuth(token),

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/botocore/vendored/requests/sessions.py", line 465, in request

  resp = self.send(prep, **send_kwargs)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/botocore/vendored/requests/sessions.py", line 573, in send

  r = adapter.send(request, **kwargs)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/botocore/vendored/requests/adapters.py", line 370, in send

  timeout=timeout

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 544, in urlopen

  body=body, headers=headers)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 341, in _make_request

  self._validate_conn(conn)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn

  conn.connect()

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/connection.py", line 238, in connect

  ssl_version=resolved_ssl_version)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ssl_wrap_socket.py", line 395, in ssl_wrap_socket_with_ocsp

  ).validate(server_hostname, ret.connection)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ocsp_snowflake.py", line 996, in validate

  return self._validate(hostname, cert_data, telemetry_data, do_retry, no_exception)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ocsp_snowflake.py", line 1002, in _validate

  cert_data, telemetry_data, hostname, do_retry=do_retry)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ocsp_snowflake.py", line 1184, in _validate_certificates_sequential

  issuer, subject, telemetry_data, hostname, do_retry=do_retry)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ocsp_snowflake.py", line 1153, in validate_by_direct_connection

  err = self.verify_fail_open(ex, telemetry_data)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/ocsp_snowflake.py", line 1166, in verify_fail_open

  if ex_obj.errno is ER_SERVER_CERTIFICATE_REVOKED:

AttributeError: 'APIException' object has no attribute 'errno'

During handling of the above exception, another exception occurred:



Traceback (most recent call last):

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/network.py", line 640, in _request_exec_wrapper

 **kwargs)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/network.py", line 883, in _request_exec

  raise RetryRequest(err)

snowflake.connector.network.RetryRequest: 'APIException' object has no attribute 'errno'



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

 File "/Users/avinogradov/git/crux/step_function/snowflake_update/test.py", line 25, in <module>

  schema=SCHEMA

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/__init__.py", line 33, in Connect

  return SnowflakeConnection(**kwargs)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/connection.py", line 187, in __init__

  self.connect(**kwargs)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/connection.py", line 484, in connect

  self.__open_connection()

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/connection.py", line 700, in __open_connection

  self.__authenticate(auth_instance)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/connection.py", line 931, in __authenticate

  session_parameters=self._session_parameters,

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/auth.py", line 197, in authenticate

  socket_timeout=self._rest._connection.login_timeout)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/network.py", line 521, in _post_request

  _include_retry_params=_include_retry_params)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/network.py", line 600, in fetch

  **kwargs)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/network.py", line 683, in _request_exec_wrapper

  conn, full_url, cause)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/network.py", line 713, in handle_invalid_certificate_error

  u'errno': ER_FAILED_TO_REQUEST,

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/errors.py", line 100, in errorhandler_wrapper

  connection.errorhandler(connection, cursor, errorclass, errorvalue)

 File "/Users/avinogradov/.local/share/virtualenvs/snowflake_update-WVrmvZbT/lib/python3.7/site-packages/snowflake/connector/errors.py", line 73, in default_errorhandler

  done_format_msg=errorvalue.get(u'done_format_msg'))

snowflake.connector.errors.OperationalError: 250003: Failed to execute request: 'APIException' object has no attribute 'errno'

............

客户端当前可以使用最新版本(2.0.1)来解决此问题,但稍后删除pyarrow和numpy(pip uninstall pyarrow numpy)可以减小依赖项的大小(这些依赖项由仅限私人预览)。

有没有更好的建议?

1 个答案:

答案 0 :(得分:0)

您是正确的,这是v2.0.1中已解决的问题。使用最近升级的asn1crypto 1.0.0软件包验证证书时,较旧版本的Python连接器失败。解决方法是使用asn1crypt 0.24.0。

pip install snowflake-connector-python asn1crypto==0.24.0