The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.
Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

DatabaseError: Write pandas dataframe to vertica using to_sql and vertica_python

I would like to write this dataframe to vertica database using to_sql method. So I use vertica_python module and my code is the following


import pandas as pd
import vertica_python

cxn = {"user":'myuser',
"password":'mypassword',
"host":'xx.x.x.xx',
"port":yyyy,
"database":"mydb"}

engine = vertica_python.connect(**cxn)

df = pd.DataFrame({"A":[1, 2, 3], "B":["a", "b", "c"]})

df.to_sql("df", index=False, if_exists="replace", con=engine, schema="public", dtype={"A":"int", "B":"str"})

Then i got database error which i could not fix it as follows.

DatabaseError: Execution failed on sql 'SELECT name FROM sqlite_master WHERE type='table' AND name=?;': not all arguments converted during string formatting

May I have your suggestions how to solve this problem? Thank you very much.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file