Remap Mysql tuple to dictionary
Pom
reply at group.invalid
Tue Sep 26 01:34:36 EDT 2006
Dennis Lee Bieber wrote:
> It might be more economical to perform the conversion while fetching
> the data:
>
> mdict = {}
> for rec in crsr:
> mdict[rec[0]] = rec[1:]
>
I didn't think of that. I just took the fetchall() from my first
version (where I looped through the tuples, which was very slow)
I just dropped the .fetchall() part, and as you said: it works fine,
with 1 copy less. (but it doesn't save me time)
dict((int(row[0]), row[1:]) for row in cursor)
thanks!
More information about the Python-list
mailing list