Python is my favourite progamming langauge and Greenplum Database is my key skill. So, Using both to perform some task is no surprise. At first I tried to use psycopg2 but When I started looking in Greenplum source code I found that Pivotal is using pygresql. So, I too thought using the same.
So, What is pygresql?
Pygresql is Python interface for PostgreSQL. It allows PostgreSQL queries to run through Python script.
>>>a=con.query("select * from gp_segment_configuration where hostname=mdw")>>>print(a)#This will print the result as same as psql utility
dbid|content|role|preferred_role|mode|status|port|hostname|address|replication_port|san_mounts----+-------+----+--------------+----+------+----+---------------+-------+----------------+----------1|-1|p|p|s|u|5432|mdw|mdw||>>>a.getresult()#To get result as Python tuples
[(1,-1,'p','p','s','u',5432,'mdw','mdw',None,None)]>>>a.dictresult()#To get result as Python Dictionary
[{'status':'u','replication_port':None,'dbid':1,'hostname':'mdw','preferred_role':'p','content':-1,'role':'p','mode':'s','address':'mdw','san_mounts':None,'port':5432}]
Python program to restore multiple MarkLogic Forests simultaneously. This script can be used when you have different number of forests than database forests ...
कोडाचाद्री पश्चिम घाटातील शिखरांपैकी एक आहे आणि शिमोगा जिल्ह्यातील सर्वात उंच की जिथून आपण शिखरापेक्षा खाली ढग अनुभवू शकतो. ढगांचा एक समुद्र आपण नेहमीच डोळ्य...
As a DBA, Many times we have to collect the row count for all the tables in database. Below are the two steps that can fulfill the requirement of getting the...