Select as dictionary...
M.-A. Lemburg
mal at egenix.com
Mon Oct 1 10:08:22 EDT 2007
On 2007-10-01 15:32, Besturk.Net Admin wrote:
> Hi..
> I am using python with postgresql.
> And i have a query :
>
> 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 ?
You can easily convert the above list to a dictionary:
d = dict(links)
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Oct 01 2007)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-list
mailing list