0

I have a table rate_card as shown below which I have inserted from data-frame using

 df5.to_sql('rate_card', cnx, if_exists='replace', schema='asia', index = False,method='multi') 

Current data inside table

ORG_CNTY  DEST_CNTY   KG  Cost    Version
 DE         FR         1   50     2019-12-02
 DE         FR         2   80     2019-12-02
 DE         IND        2   65     2018-12-01
 DE         US         1   70     2019-12-01

I have new set data which need to insert to table again

New data

ORG_CNTY  DEST_CNTY   KG  Cost    Version
 DE         FR         1   60     2020-06-02
 DE         FR         2   90     2020-06-02
 DE         IND        1   55     2020-06-02
 DE         US         1   80     22020-06-02

Expected Output

ORG_CNTY  DEST_CNTY   KG  Cost    Version
 DE         FR         1   50     2019-12-02
 DE         FR         2   80     2019-12-02
 DE         IND        2   65     2018-12-01
 DE         US         1   70     2019-12-01
 DE         FR         1   60     2020-06-02
 DE         FR         2   90     2020-06-02
 DE         IND        1   55     2020-06-02
 DE         US         1   80     22020-06-02

my current code is truncating and loading the table new data. I want to old data and append the new data into the table. How can this done in python?

aeapen
  • 871
  • 1
  • 14
  • 28

1 Answers1

0
df_expected = df_current.append(df_new)
nav610
  • 781
  • 3
  • 8