MCPcopy
hub / github.com/dbcli/pgcli / _handle_server_closed_connection

Method _handle_server_closed_connection

pgcli/main.py:1230–1244  ·  view source on GitHub ↗

Used during CLI execution.

(self, text)

Source from the content-addressed store, hash-verified

1228 return output, meta_query
1229
1230 def _handle_server_closed_connection(self, text):
1231 """Used during CLI execution."""
1232 try:
1233 click.secho("Reconnecting...", fg="green")
1234 self.pgexecute.connect()
1235 click.secho("Reconnected!", fg="green")
1236 except OperationalError as e:
1237 click.secho("Reconnect Failed", fg="red")
1238 click.secho(str(e), err=True, fg="red")
1239 else:
1240 retry = self.auto_retry_closed_connection or confirm("Run the query from before reconnecting?")
1241 if retry:
1242 click.secho("Running query...", fg="green")
1243 # Don't get stuck in a retry loop
1244 self.execute_command(text, handle_closed_connection=False)
1245
1246 def refresh_completions(self, history=None, persist_priorities="all"):
1247 """Refresh outdated completions

Callers 1

execute_commandMethod · 0.95

Calls 3

execute_commandMethod · 0.95
confirmFunction · 0.85
connectMethod · 0.45

Tested by

no test coverage detected