【发布时间】:2019-04-18 15:38:26
【问题描述】:
我正在寻找一种从 pandas 数据帧创建 postgres 表的方法,然后直接在 pgAdmin 中读取 postgre 表。 多亏了这个链接,我找到了一种方法:How to write DataFrame to postgres table?。
命令是:
from sqlalchemy import create_engine
engine = create_engine('postgresql://username:password@host:port/database')
df.to_sql('table_name', engine)
但是,我不知道“table_name”是什么。我必须在我的数据库中创建一个表吗?
感谢您的帮助!
【问题讨论】:
标签: python database postgresql pandas sqlalchemy