[mod_python] MySQLdb problem

yjfuk yjfuk at 126.com
Sat May 6 12:35:04 EDT 2006

I am use mod_python3.2.8,MySQL-python-1.2.1_p2,mysql5.0.20,centOS
when I run the script below(I save this script also in utf-8):
#coding: utf-8
from MySQLdb import connect
cursor = connection.cursor()
cursor.execute("INSERT INTO `fee` ( `affair` ) VALUES ('²âÊÔ')")
#'²âÊÔ' is a chinese word means test
it raise error:
Traceback (most recent call last):
  File "test.py", line 8, in ?
    cursor.execute("INSERT INTO `fee` ( `affair` ) VALUES ('²âÊÔ')")
  File "/opt/python/lib/python2.4/site-packages/MySQLdb/cursors.py", line 146, in execute
    query = query.encode(charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 40: ordinal not in range(128)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060507/fffa1bf4/attachment.html

More information about the Mod_python mailing list