带有Snowflake python连接器的ipython3笔记本电脑连接错误

时间:2019-12-23 20:09:45

标签: jupyter-notebook snowflake-data-warehouse

我正在尝试建立与Snowflake的ipython3笔记本的连接。我一直在尝试在python 3.7虚拟环境中使用python连接器

这是笔记本的内容,很基本,我出于隐私目的屏蔽了这些常量。

import snowflake.connector

ACCOUNT = 'xxxx.snowflakecomputing.com'
USER = 'xx'
PASSWORD = 'xxx'

con = snowflake.connector.connect(
  user=USER,
  password=PASSWORD,
  account=ACCOUNT,
)

# Creating a database, schema, and warehouse if none exists
con.cursor().execute("USE ROLE ACCONTADMIN")
con.cursor().execute("CREATE WAREHOUSE IF NOT EXISTS tiny_warehouse")
con.cursor().execute("CREATE DATABASE IF NOT EXISTS testdb")
con.cursor().execute("USE DATABASE testdb")
con.cursor().execute("CREATE SCHEMA IF NOT EXISTS testschema")

我遇到以下错误消息:

---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
<ipython-input-9-bdc887e54736> in <module>
      8   user=USER,
      9   password=PASSWORD,
---> 10   account=ACCOUNT,
     11 )
     12 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/__init__.py in Connect(**kwargs)
     31 
     32 def Connect(**kwargs):
---> 33     return SnowflakeConnection(**kwargs)
     34 
     35 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/connection.py in __init__(self, **kwargs)
    186 
    187         self.converter = None
--> 188         self.connect(**kwargs)
    189         self._telemetry = TelemetryClient(self._rest)
    190         self.telemetry_enabled = False

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/connection.py in connect(self, **kwargs)
    483 
    484         self.__set_error_attributes()
--> 485         self.__open_connection()
    486 
    487     def close(self, retry=True):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/connection.py in __open_connection(self)
    701         if not auth.read_temporary_credential(
    702                 self.account, self.user, self._session_parameters):
--> 703             self.__authenticate(auth_instance)
    704         else:
    705             # set the current objects as the session is derived from the id

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/connection.py in __authenticate(self, auth_instance)
    943             mfa_callback=self._mfa_callback,
    944             password_callback=self._password_callback,
--> 945             session_parameters=self._session_parameters,
    946         )
    947 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/auth.py in authenticate(self, auth_instance, account, user, database, schema, warehouse, role, passcode, passcode_in_password, mfa_callback, password_callback, session_parameters, timeout)
    195                 url, headers, json.dumps(body),
    196                 timeout=self._rest._connection.login_timeout,
--> 197                 socket_timeout=self._rest._connection.login_timeout)
    198         except ForbiddenError as err:
    199             # HTTP 403

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/network.py in _post_request(self, url, headers, body, token, timeout, _no_results, no_retry, socket_timeout, _include_retry_params)
    531                          timeout=timeout, token=token,
    532                          no_retry=no_retry, socket_timeout=socket_timeout,
--> 533                          _include_retry_params=_include_retry_params)
    534         logger.debug(
    535             u'ret[code] = {code}, after post request'.format(

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/network.py in fetch(self, method, full_url, headers, data, timeout, **kwargs)
    610                 ret = self._request_exec_wrapper(
    611                     session, method, full_url, headers, data, retry_ctx,
--> 612                     **kwargs)
    613                 if ret is not None:
    614                     return ret

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/network.py in _request_exec_wrapper(self, session, method, full_url, headers, data, retry_ctx, no_retry, token, **kwargs)
    712         except Exception as e:
    713             if not no_retry:
--> 714                 raise e
    715             logger.debug("Ignored error", exc_info=True)
    716             return {}

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/network.py in _request_exec_wrapper(self, session, method, full_url, headers, data, retry_ctx, no_retry, token, **kwargs)
    654                 return return_object
    655             self._handle_unknown_error(
--> 656                 method, full_url, headers, data, conn)
    657             return {}
    658         except RetryRequest as e:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/network.py in _handle_unknown_error(self, method, full_url, headers, data, conn)
    759                     url=full_url,
    760                 ),
--> 761                 u'errno': ER_FAILED_TO_REQUEST,
    762             })
    763 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/errors.py in errorhandler_wrapper(connection, cursor, errorclass, errorvalue)
     98             return
     99         elif connection is not None:
--> 100             connection.errorhandler(connection, cursor, errorclass, errorvalue)
    101             return
    102 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/errors.py in default_errorhandler(connection, cursor, errorclass, errorvalue)
     71             sqlstate=errorvalue.get(u'sqlstate'),
     72             sfqid=errorvalue.get(u'sfqid'),
---> 73             done_format_msg=errorvalue.get(u'done_format_msg'))
     74 
     75     @staticmethod

OperationalError: 250003: Failed to get the response. Hanging? method: post, url: https://hua48776.snowflakecomputing.com.snowflakecomputing.com:443/session/v1/login-request?re

我在2.7和3.7 python环境中都进行了尝试,并确保两个环境都具有更新的库。我看到了禁止的错误,我是否需要设置其他东西才能直接从这种类型的环境连接到雪花?

作为参考,我关注的是:the docs,但被困于尝试连接。

1 个答案:

答案 0 :(得分:2)

删除参数ACCOUNT的.snowflakecomputing.com部分。您只需要第一部分(示例代码中的xxxx)。