I don't properly understand how to use .format
for SQL statement in my case.
Can I use it to define a column name?
It works with one value, but not with whole tuples.
sql_stmt = ("""UPDATE intmt_vals SET {0} = {1} WHERE ID={2};""".format(column, values, ids))
cur.execute(sql_stmt)
column
is a key from an outter dict column = k
, e.g. 'column1'
values
are values from inner dict, vals = tuple(dict.get(k).values())
e.g. (a, b, c, d, e, f,)
ids
are keys from inner dict, e.g. ids = tuple(dict.get.(k).keys())
.e.g
(1,2,3,4,5,6)
Error
mysql.connector.errors.DataError: 1241 (21000): Operand should contain 1 column(s)
.