From c9109090d7dc3460e045fdfafecc08ad861bc959 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Sun, 4 Jan 2015 16:04:21 -0800 Subject: [PATCH] Copy databases query from psql. --- pgcli/pgexecute.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 61c363fe..3f0a55ee 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -59,7 +59,14 @@ class PGExecute(object): columns_query = '''SELECT column_name FROM information_schema.columns WHERE table_name =%s;''' - databases_query = '''SELECT datname FROM pg_database;''' + databases_query = """SELECT d.datname as "Name", + pg_catalog.pg_get_userbyid(d.datdba) as "Owner", + pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding", + d.datcollate as "Collate", + d.datctype as "Ctype", + pg_catalog.array_to_string(d.datacl, E'\n') AS "Access privileges" + FROM pg_catalog.pg_database d + ORDER BY 1;""" def __init__(self, database, user, password, host, port): (self.dbname, self.user, self.password, self.host, self.port) = \