summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2017-03-03 06:04:53 -0800
committerAmjith Ramanujam <amjith.r@gmail.com>2017-03-03 06:04:53 -0800
commit01f8f9f771cd09e2bfcc3a304e8c432c1b95b7da (patch)
tree0b6bd50118a307bc17f8d068618571c31a6fcb4d
parent9cc58b7087eb31eb1ca142a0fe4cab7814b43437 (diff)
Adjust the connection order to work around psycopg2 restriction.
-rw-r--r--pgcli/pgexecute.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py
index 9c6167ef..650e7f5e 100644
--- a/pgcli/pgexecute.py
+++ b/pgcli/pgexecute.py
@@ -185,10 +185,6 @@ class PGExecute(object):
cursor = conn.cursor()
- cursor.execute("SHOW ALL")
- db_parameters = dict(name_val_desc[:2] for name_val_desc in cursor.fetchall())
-
- pid = self._select_one(cursor, 'select pg_backend_pid()')[0]
conn.set_client_encoding('utf8')
if hasattr(self, 'conn'):
self.conn.close()
@@ -199,6 +195,11 @@ class PGExecute(object):
self.password = password
self.host = host
self.port = port
+
+ cursor.execute("SHOW ALL")
+ db_parameters = dict(name_val_desc[:2] for name_val_desc in cursor.fetchall())
+
+ pid = self._select_one(cursor, 'select pg_backend_pid()')[0]
self.pid = pid
self.superuser = db_parameters.get('is_superuser') == '1'