MCPcopy
hub / github.com/psycopg/psycopg / _check_result_for_fetch

Method _check_result_for_fetch

psycopg/psycopg/_cursor_base.py:606–630  ·  psycopg/psycopg/_cursor_base.py::BaseCursor._check_result_for_fetch
(self)

Source from the content-addressed store, hash-verified

604 )
605
606 def _check_result_for_fetch(self) -> PGresult:
607 if self.closed:
608 raise e.InterfaceError(class="st">"the cursor is closed")
609
610 if not (res := self.pgresult):
611 raise e.ProgrammingError(class="st">"no result available")
612
613 if (status := res.status) == TUPLES_OK:
614 return res
615 elif status == FATAL_ERROR:
616 raise e.error_from_result(res, encoding=self._encoding)
617 elif status == PIPELINE_ABORTED:
618 raise e.PipelineAborted(class="st">"pipeline aborted")
619 else:
620 if res.command_status:
621 detail = fclass="st">" (command status: {res.command_status.decode()})"
622 else:
623 try:
624 status_name = pq.ExecStatus(status).name
625 except ValueError:
626 status_name = fclass="st">"{status} - unknown"
627 detail = fclass="st">" (result status: {status_name})"
628 raise e.ProgrammingError(
629 fclass="st">"the last operation didn&class="cm">#x27;t produce records{detail}"
630 )
631
632 def _check_copy_result(self, result: PGresult) -> None:
633 class="st">"""

Callers 9

_scrollMethod · 0.95
fetchoneMethod · 0.80
fetchmanyMethod · 0.80
fetchallMethod · 0.80
__next__Method · 0.80
fetchoneMethod · 0.80
fetchmanyMethod · 0.80
fetchallMethod · 0.80
__anext__Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected