I have an INSERT statement that looks like:
query = "INSERT TABLE ({columns}) VALUES ({value_placeholders})".format(
columns=", ".join(my_dict.keys()),
value_placeholders=", ".join(["?"] * len(my_dict)),
)
cursor.execute(query, list(my_dict.values()))
How do I turn it into an UPDATE statement?
I've got this so far...
query = "UPDATE TABLE SET ({columns}) ({value_placeholders}) WHERE ID = ({id})".format(
columns=", ".join(my_dict.keys()),
value_placeholders=", ".join(["?"] * len(my_dict)),
id=id
)
cursor.execute(query, list(my_dict.values()))
Not sure how to join the key/value pairs in the dictionary to make it in the right format.
Edit:
my_dict ={
'key1': '1',
'key2': 'whatever',
'key3': Timestamp('1970-01-01 00:27:34.883683354'),
'key4': 'blabla',
'key5': Timestamp('1970-01-01 00:27:34.883882086'),
'ID': 11
}