470,834 Members | 1,670 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,834 developers. It's quick & easy.

MySQLdb problem

I am use mod_python3.2.8,MySQL-python-1.2.1_p2,mysql5.0.20,centOS
when I run the script below(I have also saved this script in utf-8):
#coding: utf-8
from MySQLdb import connect
connection=connect(user='root',passwd='',host='loc alhost',db='test')
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)

May 7 '06 #1
0 969

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dave Harrison | last post: by
1 post views Thread by Peter Nikolaidis | last post: by
2 posts views Thread by ws Wang | last post: by
4 posts views Thread by fedor | last post: by
1 post views Thread by Steve | last post: by
2 posts views Thread by Mondal | last post: by
11 posts views Thread by Fred | last post: by
1 post views Thread by Yi Xing | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.