Remap Mysql tuple to dictionary

Pom reply at group.invalid
Mon Sep 25 12:26:38 EDT 2006


Hello

I want to convert a Mysql resulset to a dictionary.

I made some code myself, and want to ask you if I do this the right way.

def remapmysql(a):
     return (a[0], (a[1:]))

def test_map():
     count = 100000 # count of simulated records
     l1 = range(0, count)
     l2 = range(count , 2 * count )
     l3 = range(2 * count, 3 * count )
     z1 = zip(l1, l2, l3) # simulate a mysql resultset

     d1 = dict(map(remapmysql,z1))

     return d1



More information about the Python-list mailing list