How to store the PSQL command result into an array or Python dictionary?

Поиск
Список
Период
Сортировка
От KhunSanAung
Тема How to store the PSQL command result into an array or Python dictionary?
Дата
Msg-id CAAQr1jZzbVrOd0eaj_K_GdC1wJZh5Q-OCqBxRLq3FhRGm0vcTQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: How to store the PSQL command result into an array or Python dictionary?
Re: How to store the PSQL command result into an array or Python dictionary?
Список pgsql-admin
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

В списке pgsql-admin по дате отправления:

Предыдущее
От: KhunSanAung
Дата:
Сообщение: How to create a read only user account to access to all pg database?
Следующее
От: clingareddy@vsoftcorp.com
Дата:
Сообщение: function nvl(numeric, integer) does not exist