MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / StatementError

Class StatementError

lib/sqlalchemy/exc.py:451–537  ·  view source on GitHub ↗

An error occurred during execution of a SQL statement. :class:`StatementError` wraps the exception raised during execution, and features :attr:`.statement` and :attr:`.params` attributes which supply context regarding the specifics of the statement which had an issue. The wrapp

Source from the content-addressed store, hash-verified

449
450
451class StatementError(SQLAlchemyError):
452 """An error occurred during execution of a SQL statement.
453
454 :class:`StatementError` wraps the exception raised
455 during execution, and features :attr:`.statement`
456 and :attr:`.params` attributes which supply context regarding
457 the specifics of the statement which had an issue.
458
459 The wrapped exception object is available in
460 the :attr:`.orig` attribute.
461
462 """
463
464 statement: Optional[str] = None
465 """The string SQL statement being invoked when this exception occurred."""
466
467 params: Optional[_AnyExecuteParams] = None
468 """The parameter list being used when this exception occurred."""
469
470 orig: Optional[BaseException] = None
471 """The original exception that was thrown.
472
473 """
474
475 ismulti: Optional[bool] = None
476 """multi parameter passed to repr_params(). None is meaningful."""
477
478 connection_invalidated: bool = False
479
480 def __init__(
481 self,
482 message: str,
483 statement: Optional[str],
484 params: Optional[_AnyExecuteParams],
485 orig: Optional[BaseException],
486 hide_parameters: bool = False,
487 code: Optional[str] = None,
488 ismulti: Optional[bool] = None,
489 ):
490 SQLAlchemyError.__init__(self, message, code=code)
491 self.statement = statement
492 self.params = params
493 self.orig = orig
494 self.ismulti = ismulti
495 self.hide_parameters = hide_parameters
496 self.detail: List[str] = []
497
498 def add_detail(self, msg: str) -> None:
499 self.detail.append(msg)
500
501 def __reduce__(self) -> Union[str, Tuple[Any, ...]]:
502 return (
503 self.__class__,
504 (
505 self.args[0],
506 self.statement,
507 self.params,
508 self.orig,

Callers 1

instanceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected