Assuming an existing mysql table, “user”. Assuming a single column primary key “id”. Assuming the data to be inserted is always given as a list of dictionaries, in the form: [{‘column_name1′:’valueA’, ‘column_name2′:’valueB’}, {‘column_name1′:’valueC’, ‘column_name2′:’valueD’}]. If a row is inserted with the same primary key (aka id), I’d like to just update the values of all the other columns. I understand
Tag: upsert
How to upsert pandas DataFrame to PostgreSQL table?
I’ve scraped some data from web sources and stored it all in a pandas DataFrame. Now, in order harness the powerful db tools afforded by SQLAlchemy, I want to convert said DataFrame into a Table() object and eventually upsert all data into a PostgreSQL table. If this is practical, what is a workable method of going about accomplishing this task?