Ticket #69: my-dict.diff
File my-dict.diff, 1.1 KB (added by , 19 years ago) |
---|
-
backends/mysql.py
48 48 49 49 def dictfetchone(cursor): 50 50 "Returns a row from the cursor as a dict" 51 raise NotImplementedError 51 res = {} 52 desc = cursor.description 53 row = cursor.fetchone() 54 if not row: 55 return None 56 for col in enumerate(row): 57 res[desc[col[0]][0]] = col[1] 58 return res 52 59 53 60 def dictfetchmany(cursor, number): 54 61 "Returns a certain number of rows from a cursor as a dict" 55 raise NotImplementedError 62 ls = [] 63 for i in range(number): 64 ls.append(dictfetchone(cursor)) 65 return ls 56 66 57 67 def dictfetchall(cursor): 58 68 "Returns all rows from a cursor as a dict" 59 raise NotImplementedError 69 ls = [] 70 row = dictfetchone(cursor) 71 while row != None: 72 ls.append(row) 73 row = dictfetchone(cursor) 74 return ls 60 75 61 76 def get_last_insert_id(cursor, table_name, pk_name): 62 77 cursor.execute("SELECT LAST_INSERT_ID()")