Q: How to update a record in database based on a variable in Python? How can I update a record in a database based on a variable?
I have a variable named run_time_start that is previously sent to the database.
But then, at some point, I want to update 2 columns in the same record, with the values of the variables end_date and total_time
is there any way I can do something like this?
engine.execute("UPDATE control_general_log SET (end_date, total_time) VALUES (?, ?)", run_time_end, total_elapsed_time, "WHERE chain_script = ?", run_time_start)


A: try this:
engine.execute("UPDATE control_general_log SET end_date=?, total_time=? WHERE chain_script = ?", (run_time_end, total_elapsed_time, run_time_start,)

conn.commit()  # conn is your connection variable

