I have a existing data table named table below:
column_a column_b column_c
1 2 "r1"
4 5 "r2"
0 0 "r3"
I want to update the data to table with a panda dataframe below:
column_a column_b column_c
7 8 "r1"
9 10 "r2"
How do pass the value to the parameters in the query I So the result should look like this below?
column_a column_b column_c
7 8 "r1"
9 10 "r2"
0 0 "r3"
I can only manage to manually enter the value in the sqlAchemy function which show below, I do not know how to use python apply function to apply all the rows in the panda dataframe. Thanks in advance!
The SqlAlchemy custom query I'm using:
with engine.connect() as connection:
connection.execute(text("UPDATE table SET column_a=:val1, column_b=:val2 WHERE column_c = :val3" ),
{'val1': 7, 'val2': 8, 'val3': "r1"})