2
votes

I am working on a scenario where I will have to do some ETL-like operations in Python where the database is Snowflake. I am new to Python and after installing the pip for the Python and Snowflake connector, I am trying to run a simple code for doing a select * from a table. I added bits and pieces of code from various sources with a view to understand how the process works. I am getting the below error and unfortunately am not able to find anything conclusive online.

Error:

OperationalError: 250003: Failed to get the response. Hanging? method: post, url: https://nq13914.southeast-asia.snowflakecomputing.com:443/session/v1/login-request?request_id=7325eb5e-eec6-4ec9-976a-6dbd00852fc3&databaseName=util_db&schemaName=public&warehouse=compute_wh&request_guid=4674d312-5cfd-4944-a8db-7dda073b7b44

Code:

import snowflake.connector as sf
import pandas


ctx = sf.connect (
    user = 'floatinginthecloud89',
    password = '',
    account = 'nq13914.southeast-asia',
    warehouse = 'compute_wh',
    database = 'util_db',
    schema = 'public'
)
print("Got the context object")

cs = ctx.cursor()
print("Got the cursor object")


try:
    cs.execute("select * from util_db.public.qwerty1;")
    df = cs.fetch_pandas_all()
    df.info()
    print("__________")
    print(df.to_string())
finally:
    cs.close()     
ctx.close()     
2

2 Answers

1
votes

Your code works for me with my own Snowflake account. Seems like your snowflake account (or the account that your company is using) is either wrong or has some Network Policy applied to it.

Using your browser, you should be able to go to https://nq13914.southeast-asia.snowflakecomputing.com/console/login#/ and see a login screen. In your case you cannot (nor can I) so the nq13914.southeast-asia is either wrong or being blocked.

0
votes

I was able to do run the script. Of the issues faced, the packages installed caused issues due to the version. So uninstalled and installed again. Had to do that a few times before it worked.