I am trying to set up a connection to an ipython3 notebook to Snowflake. I have been trying to use the python connector in a python 3.7 virtual env
This is the contents of the notebook, pretty basic, I blocked out the constants for privacy.
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")
I am running into this error message:
---------------------------------------------------------------------------
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
I tried this in both a 2.7 and 3.7 python environment and have made sure both environments have the updated libraries. I am seeing the forbidden error, do I need to set up something else to make a direct connection to snowflake from this type of environment?
For reference I was following: This guide but was stuck with trying to connect.