Skip to content Skip to sidebar Skip to footer

Operationalerror: 250003: Failed To Get The Response. Hanging? Method: Post

I am trying to connect to snowflake using my login credentials. I'm using the following code: snowflake.connector.connect( user='', password='

Solution 1:

I'm using sqlalchemy, which you can install via pip:

pip install SQLAlchemy

https://docs.snowflake.net/manuals/user-guide/sqlalchemy.html

Here's what I have at the beginning of my notebook:

import snowflake.connector
import pandas as pd
from sqlalchemy import create_engine
from snowflake.sqlalchemy import URL

url = URL(
    account = 'xxxxxxxx.east-us-2.azure',
    user = 'xxxxxxxx',
    password = 'xxxxxxxx',
    database = 'xxxxxxxx',
    schema = 'xxxxxxxx',
    warehouse = 'xxxxxxxx',
    role='xxxxxxxx'
)

engine = create_engine(url)
connection = engine.connect()

query = '''
    select 1 AS VAL;
'''

df = pd.read_sql(query, connection)

df

Solution 2:

Just Give your account name in the account .We dont need the region andfull URL.
Please check below .

----------------------------------------------------------------------
import snowflake.connector


PASSWORD ='*******'USER='<USERNAME>'
ACCOUNT ='SFCSUPPORT'
WAREHOUSE ='<WHNAME>'
DATABASE ='<DBNAME>'
SCHEMA ='PUBLIC'

print("Connecting...")
# -- (> ------------------- SECTION=connect_to_snowflake --------------------
con = snowflake.connector.connect(
  user=USER,
  password=PASSWORD,
  account=ACCOUNT,
  warehouse=WAREHOUSE,
  database=DATABASE,
  schema=SCHEMA
)


con.cursor().execute("USE WAREHOUSE " + WAREHOUSE)
con.cursor().execute("USE DATABASE " + DATABASE)
#con.cursor().execute("USE SCHEMA INFORMATION_SCHEMA")


try:
    result= con.cursor().execute("Select * from <TABLE>")
    result_list = result.fetchall()
    print(result_list)

finally:
    con.cursor().close()
con.cursor().close()

Post a Comment for "Operationalerror: 250003: Failed To Get The Response. Hanging? Method: Post"