From: | Terry Schmitt <terry(dot)schmitt(at)gmail(dot)com> |
---|---|
To: | KhunSanAung(dot)GIS(at)gmail(dot)com |
Cc: | pgsql-admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: How to store the PSQL command result into an array or Python dictionary? |
Date: | 2015-11-25 23:36:26 |
Message-ID: | CAOOcysxZenb5mo_EPzd4ftaU30DadDmz51sfOuKE86=Doz-uvQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
This does not directly answer your question, but I would seriously consider
using psycopg for all Postgres/Python development.
http://initd.org/psycopg/
This will give you much functionality in interacting with postgres.
Thanks,
Terry
On Tue, Nov 24, 2015 at 7:55 PM, KhunSanAung <khunsanaung(dot)gis(at)gmail(dot)com>
wrote:
> Hi All,
>
> I have a postgres database with 'myTable' having three columns as followed.
>
> id
>
> SubContinent
>
> Country
>
> 1
>
> South-East Asia
>
> Indonesia
>
> 2
>
> South-East Asia
>
> Thailand
>
> 3
>
> South-East Asia
>
> Malaysia
>
> 4
>
> South-East Asia
>
> Singapore
>
> 5
>
> South-East Asia
>
> Philippines
>
> 6
>
> South-East Asia
>
> Vietnam
>
> 7
>
> South-East Asia
>
> Myanmar
>
> 8
>
> South-East Asia
>
> Brunei
>
> 9
>
> South-East Asia
>
> Cambodia
>
> 10
>
> South-East Asia
>
> Laos
>
> 11
>
> South-East Asia
>
> Timor Leste
>
>
>
> I want to filter & select the table with some condition.
>
>
> SELECT SubContinent, Country from myTable WHERE Country='Thailand' ;
>
> Accessing to pgdatabase via Python is okay for me.
>
> Using the PSQL command via Python, I would like to select the columns and
> store the values in an array of dictionary like below.
>
>
> dict= {'SubContinent': 'South-East Asia', 'Country': 'Thailand'};
>
>
> How can I put the selection result into a Python dictionary?
>
>
> Any help is highly appreciate.
>
> Many thanks in advanced.
>
>
> Best regards
>
>
> --
> Have a nice day!
> --
>
> *Mr. Khun San Aung*
> * <http://geoportal.icimod.org/>*
>
From | Date | Subject | |
---|---|---|---|
Next Message | cao.wei56 | 2015-11-26 06:55:03 | I found 'LOG, 00000, "incorrect resource manager data checksum in record at 5/2CEE6930' from the replica's log |
Previous Message | Williams, Alex | 2015-11-25 21:12:30 | Re: Question on Hot Standby in PostgreSQL |