I have a pandas DataFrame df
and a PostgreSQL table my_table
. I wish to truncate my_table
and insert df
(which has columns in the same order) into my_table
, without affecting the schema of my_table
. How do I do this?
In a rather naive attempt, I tried dropping my_table
and then using pandas.DataFrame.to_sql
, but this creates a new table with a different schema.