Randy Jiang - 2011-03-21

Hi,

I want to use MySQL in python. And the following simple codes just don't work,
I don't know why.

import MySQLdb

db = MySQLdb.connect(user='root', passwd='confident', db='order_entry')

cursor = db.cursor()

name = '%Toy%'

cursor.execute("""SELECT * FROM customers WHERE name LIKE %s""", (name, ))

resut = cursor.fetchall()

cursor.close()

print(result)

When executed, I get the following error:

Traceback (most recent call last):

File "F:\projects\python\python25_mysql.py", line 4, in <module>

cursor = db.cursor()

File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line 219, in
cursor

return (cursorclass or self.cursorclass)(self)

AttributeError: 'Connection' object has no attribute 'cursorclass'

I have inspected the source code in 'connections.py', and the Connection class

does have an attribute called 'cursorclass'.

And the environments are:

Windows XP;

Python 2.5

Thanks very much.