Reputation: 121
I am trying to set up a connection with Snowflake from Python using an account which is not MFA enabled, but the connection is not made. I have attached the code and logs.
from sqlalchemy import create_engine
from snowflake.sqlalchemy import URL
from sqlalchemy.orm import sessionmaker
# # create connection object wih the
# # Bridg provided snowflake connection details provided
sf_engine = create_engine(URL(
account='xxxx',
user='xxx',
password='xxxx',
database='xxx',
schema='xxx',
warehouse='xxx',
role='xxx',
))
Session = sessionmaker(bind=sf_engine, autocommit=False)
session = Session()
results = session.execute("desc view xxx.xxx.TRANSACTION;")
print(results)
/opt/anaconda3/bin/python /Users/jpriyad/Documents/pythonProject/connect/snow.py
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1014, in __authenticate
auth.authenticate(
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/auth.py", line 257, in authenticate
ret = self._rest._post_request(
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 700, in _post_request
ret = self.fetch(
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 790, in fetch
ret = self._request_exec_wrapper(
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 912, in _request_exec_wrapper
raise e
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 844, in _request_exec_wrapper
self._handle_unknown_error(method, full_url, headers, data, conn)
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 944, in _handle_unknown_error
Error.errorhandler_wrapper(
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/errors.py", line 269, in errorhandler_wrapper
handed_over = Error.hand_to_other_handler(
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/errors.py", line 327, in hand_to_other_handler
connection.errorhandler(connection, cursor, error_class, error_value)
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/errors.py", line 203, in default_errorhandler
raise error_class(
snowflake.connector.errors.OperationalError: 250003: Failed to get the response. Hanging? method: post, url: https://xxxx.snowflakecomputing.com:443/session/v1/login-request?request_id=828cc997-d9a1-4d29-b70f-4dab2045d18f&databaseName=xxx&schemaName=xxx&warehouse=xxx&roleName=xxx&request_guid=xxxx
During handling of the above exception, another exception occurred:
File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/auth_by_plugin.py", line 117, in handle_timeout
raise OperationalError(
sqlalchemy.exc.OperationalError: (snowflake.connector.errors.OperationalError) 250001: Could not connect to Snowflake backend after 0 attempt(s).Aborting
(Background on this error at: https://sqlalche.me/e/14/e3q8)
Process finished with exit code 1
Upvotes: 7
Views: 20683
Reputation: 11
Yes i agree with the above method , for account identifier but if you facing same issues while using snowpark sessions api in instead of python connector
from snowflake.snowpark import Session
connection_parameters = {
"user": "txxxxn",
"account": "xxx.yyyy.azure",
"password": "xxx",
"role": "ACCOUNTADMIN",
"warehouse": "xxxx",
"database": "xxxx",
"schema": "xxxx"}
test_session = Session.builder.configs(connection_parameters).create()
print('connected')
Note:-
Upvotes: 1
Reputation: 724
I was facing the same issue for awhile. It took me a long time to debug it.
Solution:
recheck the credential you are passing in account
.
Wrong credential => account = 'xyz.us-east-1.snowflakecomputing.com'
correct credential => account = 'xyz.us-east-1'
Here us-east-1
is AWS region. It can be different for you.
Basically, don't pass snowflakecomputing.com
in the account credential.
Upvotes: 16