I have a pandas dataframe, I can add a table to SQL with this :
df.to_sql(table_name, engine, if_exists='append')
But since I don't want to have overlapping data for the same date column, I need to merge the new data AND to update indexes.
Consider current DB
index date value
0 1-1-2002 15
1 1-2-2002 34
Now I have a new pandas df to add:
index date value
0 1-2-2002 34
1 1-3-2002 12
I need to get at the end :
index date value
0 1-1-2002 15
1 1-2-2002 34
2 1-3-2002 12
Is there a simple way to insert my pandas to the Postgresql (I am using sqlalchemy)