P
Pom
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
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