This attribute is also available as class attribute on the
:ref:`sqlstate-exceptions` classes.
+ .. autoattribute:: pgconn
+
+ Most likely it will be in `~psycopg.pq.ConnStatus.BAD` state;
+ however it might be useful to verify precisely what went wrong, for
+ instance checking the `~psycopg.pq.PGconn.needs_password` and
+ `~psycopg.pq.PGconn.used_password`.
+
+ .. versionadded:: 3.1
+
+ .. autoattribute:: pgresult
+
+ .. versionadded:: 3.1
+
+
.. autoexception:: Warning()
.. autoexception:: InterfaceError()
.. autoexception:: DatabaseError()
result set can be accessed by calling `~Cursor.nextset()` (:ticket:`#164`).
- Add `pq.PGconn.trace()` and related trace functions (:ticket:`#167`).
- Add *prepare_threshold* parameter to `Connection` init (:ticket:`#200`).
+- Add `Error.pgconn` and `Error.pgresult` attributes (:ticket:`#242`).
- Drop support for Python 3.6.
@property
def pgconn(self) -> Optional[PGconn]:
+ """The connection object, if the error was raised from a connection attempt.
+
+ :rtype: Optional[psycopg.pq.PGconn]
+ """
return self._pgconn if self._pgconn else None
@property
def pgresult(self) -> Optional[PGresult]:
+ """The result object, if the exception was raised after a failed query.
+
+ :rtype: Optional[psycopg.pq.PGresult]
+ """
return self._info if _is_pgresult(self._info) else None
@property