how to mysqldb dict cursors

Vaibhav.bhawsar whatpot at gmail.com
Thu Apr 24 22:50:10 EDT 2008


I have been trying to get the DictCursor working with mysqldb module but
can't seem to. I have pasted the basic connection code and the traceback
from pydev. The connection does open with the default cursor class. can't
figure this one out. many thanks.

<code>
import MySQLdb
import sys
# connect to the MySQL server
try:
    conn =
MySQLdb.connect(host="localhost",read_default_file='~/.my.cnf',db='test',cursorclass=MySQLdb.cursors.DictCursor)
    cur = conn.cursor()
    print conn
except MySQLdb.Error, e:
    print "Error %d: %s" % (e.args[0], e.args[1])
    sys.exit (1)
</code>

Traceback (most recent call last):
  File "/Users/.....src/db/test.py", line 7, in ?
    conn =
MySQLdb.connect(host="localhost",read_default_file='~/.my.cnf',db='te
st',cursorclass=MySQLdb.cursors.DictCursor)
AttributeError: 'module' object has no attribute 'cursors'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080424/79d9445a/attachment.html>


More information about the Python-list mailing list