Select as dictionary...
J. Clifford Dyer
jcd at sdf.lonestar.org
Mon Oct 1 09:57:46 EDT 2007
On Mon, Oct 01, 2007 at 06:32:07AM -0700, Besturk.Net Admin wrote regarding Select as dictionary...:
>
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
> print links
>
> and result
> [(1, 5), (2,5).......] (2 million result)
>
> I want to see this result directly as a dictionary:
>
> {1: 5, 2: 5 .....}
>
> How do i select in this format ?
>
Try this:
aia.execute("SELECT id, w from list")
links=aia.fetchall()
linkdict = dict()
for k,v in links:
linkdict[k] = v
print linkdict
Cheers,
Cliff
More information about the Python-list
mailing list