Encoding trouble

Benedict Verheyen benedict.verheyen at gmail.com
Wed Dec 15 08:16:36 EST 2010


On 15/12/2010 12:34, Romaric DEFAUX wrote:
<snip>
> To create these query, I do this :
> query = "UPDATE website SET client_name='%s' WHERE ip='%s'" % (self.client_name, self.ip)
> then self.cursor.execute(query)
> 

Unicode can be tricky.
Don't you have to encode the string again?
I tested this in the interpreter:

a = ("UPDATE website SET client_name='%s'" % "Romariqué Admin").decode("iso-8859-15")

print "Query %s " % a.encode("iso-8859-15")
produces UPDATE website SET client_name='Romariqué Admin'

So i would try to encode the query before issuing the self.cursor.execute(query)

Cheers,
Benedict




More information about the Python-list mailing list