Errors¶
Errors and retries shows the hierarchy and how to act on it.
Driver failures, distinct from cancellation of the calling asyncio task.
Error
¶
Base class of every error Gres raises.
dispatch_state, connection_invalidated and transaction_outcome say what is
known about the failed call's effect.
phase
property
¶
phase: Literal['bind', 'describe', 'encode', 'decode'] | None
Local step that failed, or None for server and connection failures.
'bind' is placeholder lookup, 'describe' type resolution, 'encode'
parameter conversion and 'decode' result conversion.
parameter_position
property
¶
parameter_position: int | None
One-based parameter position in the caller's SQL, when known.
parameter_name
property
¶
parameter_name: str | None
Named SQL placeholder without its dollar prefix.
column_index
property
¶
column_index: int | None
Zero-based result column for a local conversion failure.
column_name
property
¶
column_name: str | None
Result column label, or the column reported by PostgreSQL.
postgres_type
property
¶
postgres_type: str | None
Diagnostic name of the expected PostgreSQL type, when known.
python_type
property
¶
python_type: type[object] | None
Type of the rejected Python input, without retaining the value.
dispatch_state
property
¶
dispatch_state: Literal['not_sent', 'possibly_sent'] | None
Whether the statement may have reached PostgreSQL.
'not_sent' if it never did, 'possibly_sent' if it may have executed, and
None if the call was refused before it started.
connection_invalidated
property
¶
connection_invalidated: bool | None
Whether this failure discarded the PostgreSQL session.
A pool replaces the session; a Connection is closed.
transaction_outcome
property
¶
transaction_outcome: (
Literal['committed', 'rolled_back', 'released', 'unknown'] | None
)
How a managed transaction ended when its commit, rollback or release failed.
None for other errors.
ConfigurationError
¶
An invalid or unsupported connection setting.
InterfaceError
¶
The resource cannot accept this operation.
NotificationOverflowError
¶
The notification queue filled. Reconcile application state and start a new listener.
PoolBusyError
¶
Physical capacity is occupied and the pool cannot admit another waiter.
ServerError
¶
PostgreSQL rejected the operation; sqlstate identifies the condition.
position
property
¶
position: int | None
One-based character position in the statement reported by PostgreSQL.
IntegrityError
¶
PostgreSQL rejected a change that would violate an integrity constraint.
DataError
¶
PostgreSQL could not process the supplied data.
ProgrammingError
¶
PostgreSQL rejected the SQL syntax, object reference or access rule.
OperationalError
¶
PostgreSQL reported an operational failure, such as a serialization conflict.
NotSupportedError
¶
PostgreSQL does not support the requested feature.
InternalError
¶
PostgreSQL reported an internal error or invalid transaction state.
UniqueViolation
¶
A unique constraint rejected a duplicate key (23505).
ForeignKeyViolation
¶
A foreign key constraint would be violated (23503).
NotNullViolation
¶
A NULL was rejected by a NOT NULL constraint (23502).
CheckViolation
¶
A CHECK constraint rejected the row (23514).
ExclusionViolation
¶
An exclusion constraint rejected a conflicting row (23P01).
SerializationFailure
¶
PostgreSQL could not serialize the transaction (40001).
DeadlockDetected
¶
PostgreSQL aborted the operation to resolve a deadlock (40P01).
LockNotAvailable
¶
A NOWAIT lock request or lock_timeout could not obtain the lock (55P03).
QueryCanceled
¶
PostgreSQL canceled the statement, for example at statement_timeout (57014).
ReadOnlySqlTransaction
¶
A write was attempted in a read-only transaction or on a standby (25006).
ConnectionError
¶
The physical session could not be established or retained.
TransactionLostError
¶
The session can no longer continue the managed transaction.
CommitOutcomeUnknownError
¶
COMMIT may have reached PostgreSQL, but no conclusive response was observed.
ProtocolError
¶
A backend message did not fit the current protocol exchange.
QueryShapeError
¶
The statement requested a transfer the selected method cannot supply.
DecodingError
¶
A decoded SQL value cannot be represented by the chosen result.
EncodingError
¶
A parameter cannot be encoded as the destination PostgreSQL type.
UnsupportedTypeError
¶
No installed codec can supply the requested SQL type.
CardinalityError
¶
A completed statement returned the wrong number of rows.
TimeoutError
¶
TimeoutError(message: str, *, sent: bool, invalidated: bool = False)
The driver's monotonic budget expired, not an external task cancellation.