I can’t find the solution through google.
How do I check if existing data in the table and compare it with output table from my script? Then take the data and do the following:
if the data exists do not do anything.
if the new data set has an update new row. delete the old data and replace with new data
if the data does not exist. Append the new data.
For the Pandas to_sql, I do not want to use the “replace” function because I do not want to delete the entire table and replace it.
Let me know what you guys think.
I didn’t understand if both the tables are in the database or one is a pandas dataframe and the other is a data-table.
In case they are both data tables (in DB), have you tried something similar? - https://stackoverflow.com/questions/15926953/compare-two-tables-find-missing-rows-and-mismatched-data
One is a SQL file and the other is a CSV File. The goal is to compare the sql table and CSV file.
Then do the following:
if the same exact data exists in the CSV and SQL Table no change in the SQL table.
if the new data in the CSV file update the new row in the SQL table. delete the old data in the SQL table and replace with new data in the SQL Table
if the data in the SQL Table does not exist. Append the new data.
I probably should have clarify before.