mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 21:00:33 +03:00
Added documentation for 'Error.pgerror' and 'Error.pgcode' attributes.
This commit is contained in:
parent
c72dc3af00
commit
e4d427aae6
|
@ -93,6 +93,39 @@ available through the following exceptions:
|
||||||
are not considered errors and thus should not use this class as base. It
|
are not considered errors and thus should not use this class as base. It
|
||||||
is a subclass of the Python |StandardError|_.
|
is a subclass of the Python |StandardError|_.
|
||||||
|
|
||||||
|
.. attribute:: pgerror
|
||||||
|
|
||||||
|
String representing the error message returned by the backend,
|
||||||
|
``None`` if not available.
|
||||||
|
|
||||||
|
.. attribute:: pgcode
|
||||||
|
|
||||||
|
String representing the error code returned by the backend, ``None``
|
||||||
|
if not available. The :mod:`~psycopg2.errorcodes` module contains
|
||||||
|
symbolic constants representing PostgreSQL error codes.
|
||||||
|
|
||||||
|
.. extension::
|
||||||
|
|
||||||
|
The :attr:`~Error.pgerror` and :attr:`~Error.pgcode` attributes are
|
||||||
|
Psycopg extensions. ::
|
||||||
|
|
||||||
|
>>> try:
|
||||||
|
... cur.execute("SELECT * FROM barf")
|
||||||
|
>>> except Exception, e:
|
||||||
|
.... pass
|
||||||
|
|
||||||
|
>>> e.pgcode
|
||||||
|
>>> '42P01'
|
||||||
|
>>> print e.pgerror
|
||||||
|
ERROR: relation "barf" does not exist
|
||||||
|
LINE 1: SELECT * FROM barf
|
||||||
|
^
|
||||||
|
|
||||||
|
.. versionchanged:: 2.0.7 added :attr:`Error.pgerror` and
|
||||||
|
:attr:`Error.pgcode` attributes.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. exception:: InterfaceError
|
.. exception:: InterfaceError
|
||||||
|
|
||||||
Exception raised for errors that are related to the database interface
|
Exception raised for errors that are related to the database interface
|
||||||
|
|
Loading…
Reference in New Issue
Block a user