I am trying to execute the following code:
import MySQLdb
import MySQLdb.cursors
conn=MySQLdb.connect(host = '127.0.0.1',
user = 'root',
passwd = 'root',
db = 'test',
cursorclass = MySQLdb.cursors.DictCursor)
cursor=conn.cursor()
But it gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 243, in cursor
AttributeError: 'Connection' object has no attribute 'cursorclass'
Why is this?
import MySQLdb
import MySQLdb.cursors
conn=MySQLdb.connect(host = '127.0.0.1',
user = 'root',
passwd = 'root',
db = 'test',)
cursor=conn.cursor(cursorclass = MySQLdb.cursors.DictCursor)
This is a rough hack, but it may not be advisable to use it. The script with throw out dictionary object by default but the application might require an tuple or array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With