gpt4 book ai didi

sqlalchemy - Snowflake Account must be specified 错误,但已指定

转载 作者:行者123 更新时间:2023-12-05 01:27:07 24 4
gpt4 key购买 nike

我有以下代码,我有帐户、用户名、密码等,但我仍然看到以下错误:

raise error_class( sqlalchemy.exc.ProgrammingError:(snowflake.connector.errors.ProgrammingError) 251001: Account must bespecified

我也尝试过更改 created_db_engine 函数中的 engine 变量,如下所示,但我看到了同样的错误:

engine = snowflake.connector.connect(
user='USER',
password='PASSWORD',
account='ACCOUNT',
warehouse='WAREHOUSE',
database='DATABASE',
schema='SCHEMA'
)

这是我的代码

import pandas as pd
from snowflake.sqlalchemy import URL
from sqlalchemy import create_engine
import snowflake.connector
from snowflake.connector.pandas_tools import write_pandas, pd_writer
from pandas import json_normalize
import requests


df = 'my_dataframe'


def create_db_engine(db_name, schema_name):
engine = URL(
account="ab12345.us-west-2.snowflakecomputing.com",
user="my_user",
password="my_pw",
database="DB",
schema="PUBLIC",
warehouse="WH1",
role="DEV"
)
return engine


def create_table(out_df, table_name, idx=False):
url = create_db_engine(db_name="db", schema_name="skm")
engine = create_engine(url)
connection = engine.connect()

try:
out_df.to_sql(
table_name, connection, if_exists="append", index=idx, method=pd_writer
)

except ConnectionError:
print("Unable to connect to database!")

finally:
connection.close()
engine.dispose()

return True

print(df.head)

create_table(df, "reporting")

最佳答案

鉴于 Snowflake documentation for SqlAlchemy ,您的帐户参数不应包含snowflakecomputing.com

因此您应该尝试使用 ab12345.us-west-2,连接器会自动为您附加域部分。

关于sqlalchemy - Snowflake Account must be specified 错误,但已指定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69771891/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com