$72 GRAYBYTE WORDPRESS FILE MANAGER $65

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/python37/share/doc/alt-python37-psycopg2/doc/src/

HOME
Current File : /opt/alt/python37/share/doc/alt-python37-psycopg2/doc/src//errorcodes.rst
`psycopg2.errorcodes` -- Error codes defined by PostgreSQL
===============================================================

.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>

.. index::
    single: Error; Codes

.. module:: psycopg2.errorcodes

.. testsetup:: *

    from psycopg2 import errorcodes

.. versionadded:: 2.0.6

This module contains symbolic names for all PostgreSQL error codes and error
classes codes.  Subclasses of `~psycopg2.Error` make the PostgreSQL error
code available in the `~psycopg2.Error.pgcode` attribute.

From PostgreSQL documentation:

    All messages emitted by the PostgreSQL server are assigned five-character
    error codes that follow the SQL standard's conventions for :sql:`SQLSTATE`
    codes.  Applications that need to know which error condition has occurred
    should usually test the error code, rather than looking at the textual
    error message.  The error codes are less likely to change across
    PostgreSQL releases, and also are not subject to change due to
    localization of error messages. Note that some, but not all, of the error
    codes produced by PostgreSQL are defined by the SQL standard; some
    additional error codes for conditions not defined by the standard have
    been invented or borrowed from other databases.

    According to the standard, the first two characters of an error code
    denote a class of errors, while the last three characters indicate a
    specific condition within that class. Thus, an application that does not
    recognize the specific error code can still be able to infer what to do
    from the error class.

.. seealso:: `PostgreSQL Error Codes table`__

    .. __: https://www.postgresql.org/docs/current/static/errcodes-appendix.html#ERRCODES-TABLE


An example of the available constants defined in the module:

    >>> errorcodes.CLASS_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
    '42'
    >>> errorcodes.UNDEFINED_TABLE
    '42P01'

Constants representing all the error values defined by PostgreSQL versions
between 8.1 and 12 are included in the module.


.. autofunction:: lookup(code)

    .. doctest::

        >>> try:
        ...     cur.execute("SELECT ouch FROM aargh;")
        ... except Exception as e:
        ...     pass
        ...
        >>> errorcodes.lookup(e.pgcode[:2])
        'CLASS_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION'
        >>> errorcodes.lookup(e.pgcode)
        'UNDEFINED_TABLE'

    .. versionadded:: 2.0.14


.. testcode::
    :hide:

    conn.rollback()

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
31 Aug 2024 3.40 AM
root / root
0755
_static
--
31 Aug 2024 3.40 AM
root / root
0755
tools
--
31 Aug 2024 3.40 AM
root / root
0755
Makefile
3.309 KB
20 Oct 2019 7.45 AM
root / root
0644
advanced.rst
21.903 KB
20 Oct 2019 7.45 AM
root / root
0644
conf.py
8.267 KB
20 Oct 2019 7.45 AM
root / root
0644
connection.rst
33.257 KB
20 Oct 2019 7.45 AM
root / root
0644
cursor.rst
23.048 KB
20 Oct 2019 7.45 AM
root / root
0644
errorcodes.rst
2.455 KB
20 Oct 2019 7.45 AM
root / root
0644
errors.rst
2.896 KB
20 Oct 2019 7.45 AM
root / root
0644
extensions.rst
32.812 KB
20 Oct 2019 7.45 AM
root / root
0644
extras.rst
35.607 KB
20 Oct 2019 7.45 AM
root / root
0644
faq.rst
14.587 KB
20 Oct 2019 7.45 AM
root / root
0644
index.rst
1.833 KB
20 Oct 2019 7.45 AM
root / root
0644
install.rst
10.31 KB
20 Oct 2019 7.45 AM
root / root
0644
license.rst
0.074 KB
20 Oct 2019 7.45 AM
root / root
0644
module.rst
13.035 KB
20 Oct 2019 7.45 AM
root / root
0644
news.rst
0.105 KB
20 Oct 2019 7.45 AM
root / root
0644
pool.rst
1.822 KB
20 Oct 2019 7.45 AM
root / root
0644
sql.rst
3.021 KB
20 Oct 2019 7.45 AM
root / root
0644
tz.rst
0.529 KB
20 Oct 2019 7.45 AM
root / root
0644
usage.rst
40.679 KB
20 Oct 2019 7.45 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF