Reputation: 110452
I used to be able to do something like:
self.conn = MySQLdb.connect(user=...)
self.dict_cursor = self.conn.cursor(MySQLdb.cursors.DictCursor)
However, now it's not so simple with the new mysql-python connector. How would I do a similar pattern to initialize a dict cursor?
self.conn = mysql.connector.connect(user=...)
self.dict_cursor = self.conn ???
Upvotes: -1
Views: 34
Reputation: 113
Have you tried self.dict_cursor = self.conn.cursor()
? I'm not quite sure what MySQLdb.cursors.DictCursor
should be but I remember creating cursors in mysql-python like so.
Also, this might help: python mysql.connector DictCursor?
(result: self.dict_cursor = self.conn.cursor(dictionary=True)
if you have mysql-python is atleast v2, source: first comment of first answer)
Upvotes: 3