mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
Added doc for Error.cursor
This commit is contained in:
parent
db987250c8
commit
78895e6943
|
@ -117,29 +117,28 @@ available through the following exceptions:
|
||||||
if not available. The `~psycopg2.errorcodes` module contains
|
if not available. The `~psycopg2.errorcodes` module contains
|
||||||
symbolic constants representing PostgreSQL error codes.
|
symbolic constants representing PostgreSQL error codes.
|
||||||
|
|
||||||
|
.. doctest::
|
||||||
|
:options: +NORMALIZE_WHITESPACE
|
||||||
|
|
||||||
|
>>> 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
|
||||||
|
^
|
||||||
|
.. attribute:: cursor
|
||||||
|
|
||||||
|
The cursor the exception was raised from; `None` if not applicable.
|
||||||
|
|
||||||
.. extension::
|
.. extension::
|
||||||
|
|
||||||
The `~Error.pgerror` and `~Error.pgcode` attributes are
|
The `~Error.pgerror`, `~Error.pgcode`, and `~Error.cursor` attributes
|
||||||
Psycopg extensions.
|
are Psycopg extensions.
|
||||||
|
|
||||||
.. doctest::
|
|
||||||
:options: +NORMALIZE_WHITESPACE
|
|
||||||
|
|
||||||
>>> 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 `Error.pgerror` and
|
|
||||||
`Error.pgcode` attributes.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. exception:: InterfaceError
|
.. exception:: InterfaceError
|
||||||
|
|
Loading…
Reference in New Issue
Block a user