How do I write a pandas dataframe to Vertica?

淺唱寂寞╮ 提交于 2019-12-01 23:55:28

Often when connecting to Vertica, you can use Postgresql as a stand-in since certain parts of Vertica were originally based on Postgresql.

from sqlalchemy import create_engine
engine = create_engine('postgresql://user:pass@host:5433/MYDB')
df.to_sql('table_name', engine)

If this doesn't work you could try out the vertica-sqlalchemy package.

Also, depending on the SQL created (and if the ODBC driver converts INSERT to a COPY) this might be very slow. If you find that it is doing lots of individual inserts on the database, you'll probably want to switch to a COPY method where you create strings and COPY FROM STDIN to make it faster.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!