【发布时间】:2021-12-16 18:53:21
【问题描述】:
我正在尝试将数据帧上传到 Heroku postgreSQL 服务器,我之前已经成功完成了几次。
这是我的代码,for_db 是我的 Pandas 数据框的名称:
from sqlalchemy import create_engine
engine = create_engine('postgresql://wgam{rest of url}',
echo=False)
# attach the data frame to the sql server
for_db.to_sql('phil_nlp',
con = engine,
if_exists='replace')
起初,它无法连接,因为 Heroku 给我的服务器 URL 一开始只有“postgres”,但我知道它必须更改为“postgresql”才能正常工作并且已经克服了最初的错误.
现在我遇到了一个新错误。
/usr/local/lib/python3.7/dist-packages/sqlalchemy/dialects/postgresql/psycopg2.py in do_executemany(self, cursor, statement, parameters, context)
899 template=executemany_values,
900 fetch=bool(context.compiled.returning),
--> 901 **kwargs
902 )
903
TypeError: execute_values() got an unexpected keyword argument 'fetch'
我不明白为什么会出现这种情况。显然我从未指定过这样的关键字参数。我做了很多搜索,没有任何好的结果。有谁知道为什么它现在会在上周才起作用的代码中抛出这个错误?
【问题讨论】:
标签: postgresql heroku