2006年07月01日 星期六 10:35
For my system has no chinese input, so it is a english mail:(
I want to use MySQLdb to access mysql database, a part of my code is
below:
==============================================================================
# connect database using root
try:
db = MySQLdb.connect(host='localhost',user='root',passwd='appla141620')
except:
print 'Fail to connect database:',dbparam[0],',',dbparam[1]
sys.exit(-1)
# create database
c = db.cursor()
c.execute("create database if not exists " + dbparam[4])
c.close()
db.commit()
db.close()
sys.exit(-1)
==============================================================================
when it runs to c.execute("......"), a exception is raised:
Traceback (most recent call last):
File "./builddb.py", line 101, in ?
c.execute("create database if not exists " + dbparam[4])
File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 146, in
execute
query = query.encode(charset)
LookupError: unknown encoding: latin1_swedish_ci
==============================================================================
the softwares are:
redhat-fedora-c3
MySQL 4.1.20-standard
MySQL-python-1.2.1_p2
Python 2.3.4 (#1, Feb 2 2005, 12:11:53) [GCC 3.4.2 20041017 (Red Hat
3.4.2-6.fc3)] on linux2
==============================================================================
It maybe a small problem, I have searched many materials, but have not
solved it yet,
desire your help and thanks all very much.
best regards
jinyi
2006/07/01
Zeuux © 2025
京ICP备05028076号