Skip to content

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

@zudevon

Description

@zudevon

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions