Pandas to_sql 不会在我的表中插入任何数据 [英] Pandas to_sql doesn't insert any data in my table

查看:52
本文介绍了Pandas to_sql 不会在我的表中插入任何数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我创建的表中插入一些数据.我有一个如下所示的数据框:

I am trying to insert some data in a table I have created. I have a data frame that looks like this:

我创建了一个表:

create table online.ds_attribution_probabilities
(
attribution_type text,
channel text,
date date ,
value float
)

我正在运行这个 python 脚本:

And I am running this python script:

engine = create_engine("postgresql://@e.eu-central-1.redshift.amazonaws.com:5439/mdhclient_encoding=utf8")
connection = engine.raw_connection()
result.to_sql('online.ds_attribution_probabilities', con=engine, index = False, if_exists = 'append')

我没有出错,但是当我检查表中没有数据时.有什么问题?我是否必须提交或执行额外的步骤?

I get no error, but when I check there are no data in my table. What can be wrong? Do I have to commit or do an extra step?

推荐答案

尝试指定架构名称:

result.to_sql('ds_attribution_probabilities', con=engine, 
              schema='online', index=False, if_exists='append')

这篇关于Pandas to_sql 不会在我的表中插入任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆