Here is an example:
import MySQLdb
column = str(MySQLdb.escape_string(row[1]))
query = "update myTable set %(column)s = %%s where ID = %%s" % dict(column = column)
cursor2.execute(query, [row[3], row[0]])
Refresh
Here is a brief comment:
column = str(MySQLdb.escape_string(row[1]))
It is always a good idea to avoid everything that is included in the request. In this case, we dynamically add the column name and, therefore, it must be escaped before executing the query.
query = "update myTable set %(column)s = %%s where ID = %%s" % dict(column = column)
. : (1) , column, (2), , .
dict(column = column) - {'column': column}. dict.
, , (%%).
cursor2.execute(query, [row[3], row[0]])
, . , update myTable set column_name = %s where ID = %s.