aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/python/pgext.py
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1998-12-17 01:43:04 +0000
committerBruce Momjian <bruce@momjian.us>1998-12-17 01:43:04 +0000
commite9491eb91c268166d3694ff3289b43ff5acb1892 (patch)
treeb338bf03b83a1a2c49acc7fd71dcab66bbce4568 /src/interfaces/python/pgext.py
parentc13a64d7fb3002f437fdf9ab28120c00d0853d04 (diff)
downloadpostgresql-e9491eb91c268166d3694ff3289b43ff5acb1892.tar.gz
postgresql-e9491eb91c268166d3694ff3289b43ff5acb1892.zip
Upgrade to Pygress 2.2.
Diffstat (limited to 'src/interfaces/python/pgext.py')
-rw-r--r--src/interfaces/python/pgext.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/interfaces/python/pgext.py b/src/interfaces/python/pgext.py
index 97c7e342bfc..f1a7cfa6062 100644
--- a/src/interfaces/python/pgext.py
+++ b/src/interfaces/python/pgext.py
@@ -10,34 +10,30 @@ def doconnect(dbname = None, host = None, port = None, opt = None, tty = None):
# list all databases on the server
def ListDB(pgcnx):
- result = pgcnx.query("select datname from pg_database")
list = []
- for node in result:
- list.append(result[i][0])
+ for node in pgcnx.query("SELECT datname FROM pg_database").getresult():
+ list.append(node[0])
return list
# list all tables (classes) in the selected database
def ListTables(pgcnx):
- result = pgcnx.query("select relname from pg_class " \
- "where relkind = 'r' " \
- " and relname !~ '^Inv' " \
- " and relname !~ '^pg_'")
list = []
- for node in result:
+ for node in pgcnx.query("""SELECT relname FROM pg_class
+ WHERE relkind = 'r' AND
+ relname !~ '^Inv' AND
+ relname !~ '^pg_'""").getresult():
list.append(node[0])
return list
# list table fields (attribute) in given table
def ListAllFields(pgcnx, table):
- result = pgcnx.query("select c.relname, a.attname, t.typname " \
- "from pg_class c, pg_attribute a, pg_type t " \
- "where c.relname = '%s' " \
- " and a.attnum > 0" \
- " and a.attrelid = c.oid" \
- " and a.atttypid = t.oid " \
- "order by relname, attname" % table)
- # personnal preference ... so I leave the original query
list = []
- for node in result:
+ for node in pgcnx.query("""SELECT c.relname, a.attname, t.typname
+ FROM pg_class c, pg_attribute a, pg_type t
+ WHERE c.relname = '%s' AND
+ a.attnum > 0 AND
+ a.attrelid = c.oid AND
+ a.atttypid = t.oid
+ ORDER BY relname, attname""" % table).getresult():
list.append(node[1], node[2])
return list