Skip to content

Commit

Permalink
Fix for dbcli#1014.
Browse files Browse the repository at this point in the history
  • Loading branch information
j-bennet committed Mar 18, 2019
1 parent 72f6b6a commit d25d278
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pgcli/pgexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,13 @@ def run(self, statement, pgspecial=None, exception_formatter=None,
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
Expand Down

0 comments on commit d25d278

Please sign in to comment.