0
votes

On my example below, I am using sqlalchemy orm to update the values of a column (column_2) conditional to the values of another column (column_1).

I am currently using two updates to achieve that.

Is it possible to combine these two updates into one? That would save the second execute on my code below.

update_1 = update(table).where(table.c[column_1] != "ABC").values({table.c[column_2]:(table.c[column_3] * table.c[column_4]) })

db.execute(update_1)

update_2 = update(table).where(table.c[column_1] == "ABC").values({table.c[column_2]:table.c[column_3] })

db.execute(update_2)