Reputation: 646
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)
Upvotes: 1
Views: 56
Reputation: 26
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
Upvotes: 1