def todict(db, row):
 d = {}
 for (i, field) in enumerate(db.cursor.description):
  column = field[0].lower()
  d[column] = row[i]
 return d

def todict ( db , row ) : d = { } for ( i , field ) in enumerate ( db . cursor . description ) : column = field [ 0 ] . lower ( ) d [ column ] = row [ i ] return d
transforms a row into a dict keyed by column names .