在Python中运行雪花查询



我正在处理一个场景,我将不得不在Python中做一些类似etl的操作,其中数据库是雪花。我是Python的新手,在安装Python和雪花连接器的pip后,我试图运行一个简单的代码,用于从表中执行select *。为了理解这个过程是如何工作的,我从各种来源添加了一些代码片段。我得到以下错误,不幸的是,我无法在网上找到任何结论性的东西。

错误:

OperationalError: 250003: Failed to get the response。挂吗?方法: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

代码:

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()     

您的代码为我工作与我自己的雪花帐户。似乎您的雪花帐户(或您公司正在使用的帐户)要么是错误的,要么是应用了某些网络策略。

使用浏览器,您应该能够访问https://nq13914.southeast-asia.snowflakecomputing.com/console/login#/并看到一个登录屏幕。在你的情况下,你不能(我也不能),所以nq13914.southeast-asia要么是错误的,要么是被阻塞的。

我能够运行脚本。在面临的问题中,安装的软件包由于版本导致了问题。所以卸载并重新安装。我试了好几次才成功。

最新更新