Unicode from Web to MySQL
Skip Montanaro
skip at pobox.com
Sun Dec 28 19:29:26 EST 2003
>> That's because you're trying to create SQL statements manually.
Bill> As opposed to what?
Let MySQLdb do the data escaping for you:
conn = MySQLdb.Connection(host=..., etc)
curs = conn.cursor()
curs.execte("insert into sometable"
" (field1, field2)"
" values"
" (%s, %s)",
(val1, val2))
Val1 and val2 can be utf-8-encoded strings. MySQLdb will do the right thing
for you...
Skip
More information about the Python-list
mailing list