Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If table exists, then append and replace do not work when adding a dataframe to a table #110

Open
zudevon opened this issue Apr 12, 2021 · 2 comments

Comments

@zudevon
Copy link

zudevon commented Apr 12, 2021

In the sqlalchemy clinet, when I try to replace or append a pandas dataframe to a table, if it exists, I get the error of the table already existing.

When I append I get this error:
ProgrammingError: (psycopg2.errors.DuplicateTable)

When I replace I get this error:
ProgrammingError: (psycopg2.errors.DuplicateTable)

The code is similar to: (both df's are in same format, and have same columns)

dataframe_to_table(df, table="my_table")
dataframe_to_table(df2, table="my_table", if_exists="replace")   # or if_exists="append"

The only solution I have had to work around this is to query the table, concatenate with the new dataframe, drop my table and then recreate it with just using the dataframe_to_table method

Is this method broken?

@alaukikharsh
Copy link

is this still an issue?

@zudevon
Copy link
Author

zudevon commented Jan 21, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants