How can I use the CursorUseResultMixIn in MySQLdb. The obvious thing to do was:
con=MySQLdb.connect(host='localhost', user='test', passwd='xx', db='yy')
curs = con.cursor(MySQLdb.cursors.CursorUseResultMixIn)
but this gives me this error:
File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line 226, in cursor
return (cursorclass or self.cursorclass)(self)
TypeError: object.__new__() takes no parameters
What am I doing wrong?
The
MySQLdb.cursorsmodule usesCursorUseResultMixInlike this:That is literally the entire definition of
SSCursor.Unless you have a specific need to subclass BaseCursor differently, you could just use
SSCursorlike this:PS. There is also a
cursors.SSDictCursorwhich returns rows as dictionaries, while storing the result set in the server.PPS. On Ubuntu 11.10, the
MySQLdb.cursorsmodule is typically located at/usr/lib/pymodules/python2.7/MySQLdb/cursors.py.