diff options
author | Irina Truong <i.chernyavska@gmail.com> | 2019-03-04 16:52:39 -0800 |
---|---|---|
committer | Irina Truong <i.chernyavska@gmail.com> | 2019-03-18 03:09:26 +0000 |
commit | d25d27846a3f3ed7eb673a93cc9e7691b99fe36b (patch) | |
tree | 14aa01f3faa17129fe55bbc9e306ada2bb6461ee | |
parent | 72f6b6a5611c08ae22ee72d320995a35b6e45998 (diff) |
Fix for https://github.com/dbcli/pgcli/issues/1014.
-rw-r--r-- | pgcli/pgexecute.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 4deaf279..8c3bfa82 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -354,7 +354,13 @@ class PGExecute(object): if pgspecial: # First try to run each query as special _logger.debug('Trying a pgspecial command. sql: %r', sql) - cur = self.conn.cursor() + try: + cur = self.conn.cursor() + except psycopg2.InterfaceError: + # edge case when connection is already closed, but we + # don't need cursor for special_cmd.arg_type == NO_QUERY. + # See https://github.com/dbcli/pgcli/issues/1014. + cur = None try: for result in pgspecial.execute(cur, sql): # e.g. execute_from_file already appends these |