def dict_factory(cursor, row):
 d = {}
 for (idx, col) in enumerate(cursor.description):
  d[col[0]] = row[idx]
 return d

def dict_factory ( cursor , row ) : d = { } for ( idx , col ) in enumerate ( cursor . description ) : d [ col [ 0 ] ] = row [ idx ] return d
return a dictionary for the current database position .