Skip to content

Instantly share code, notes, and snippets.

@kevingo
Created January 2, 2013 15:16
What is the best escape character strategy for Python/MySQL combo
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]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment