Encoding trouble
Romaric DEFAUX
rde at audaxis.com
Wed Dec 15 06:34:21 EST 2010
Hi all,
Since yesterday I'm working on an encoding problem, I become crazy now :)
Could you please help me ?
Here's the description of the problem :
I've got two table in a MysqlDB :
history_website and website
The important column in them are :
history_website.message (varchar(255), encoding = utf8_general_ci)
website.client_name (varchar(255), encoding = utf8_general_ci)
Why :
1° ) INSERT INTO history_website (time, ip, servername, message) VALUES
('1292411324.22', '192.168.2.15', 'system_server_test.audaxis.com',
'client_name UPDATED from Romariqu to Romariqué Admin\n')
is working perfectly when
2°) UPDATE website SET client_name='Romariqué Admin\n' WHERE
ip='192.168.2.15'
is producing error :
Warning: Incorrect string value: '\xE9 Admi...' for column 'client_name'
at row 1 ???
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)
query = "INSERT INTO history_website (time, ip, servername, message)
VALUES ('%s', '%s', '%s', '%s')" % (now, self.ip, self.servername, message)"
where message = "client_name UPDATED from %s to %s" %
(old_website.client_name, self.client_name)
They're both string :
type(message) = <type 'str'>
type(client_name) = <type 'str'>
My default encoding is sys.setdefaultencoding('utf-8')
In my opinion, it should not work for both or work for both, no ? This
is strange that it's working only for one...
Romaric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5361 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20101215/30fdf3cb/attachment-0001.bin>
More information about the Python-list
mailing list