I have the dataframe below with the respective values and would like to update my SQL Database Server if the ID matches with my dataframe
df dataframe
| ID | VALUE |
|---|---|
| 123 | 9 |
| 456 | 11 |
SQL Database Server, table1
| ID | VALUE |
|---|---|
| 456 | 62 |
| 623 | 41 |
| 123 | 3 |
| 563 | 67 |
After updating, I want my SQL Database Server to look like this where you'll notice that ID 123 & 456 has been given a new value based on my dataframe.
| ID | VALUE |
|---|---|
| 456 | 11 |
| 623 | 41 |
| 123 | 9 |
| 563 | 67 |
Anyone knows how I could utilise this in my query when executing?
query = DELETE/UPDATE table table1 where ID = ID IN DATAFRAME
conn.execute(query)