.. index::
- single: Exceptions; DB API
+ single: Exceptions; DB-API
-DBAPI exceptions
-----------------
+.. _dbapi-exceptions:
-In compliance with the DB API, all the exceptions raised by ``psycopg3``
+DB-API exceptions
+-----------------
+
+In compliance with the DB-API, all the exceptions raised by ``psycopg3``
derive from the following classes:
.. parsed-literal::
.. index::
single: Exceptions; PostgreSQL
+.. _sqlstate-exceptions:
+
SQLSTATE exceptions
-------------------
Errors coming from a database server (as opposite as ones generated
client-side, such as connection failed) usually have a 5-letters error code
-called SQLSTATE (available in the ``diag.sqlstate`` attribute).
+called SQLSTATE (available in the `~Diagnostic.sqlstate` attribute of
+`Error.diag`).
``psycopg3`` exposes a different class for each SQLSTATE value, allowing to
write idiomatic error handling code according to specific conditions happening
.. __: https://www.postgresql.org/docs/current/errcodes-appendix.html#ERRCODES-TABLE
Every exception class is a subclass of one of the :ref:`standard DB-API
-exception <dbapi-exceptions>` and expose the `~Error` interface.
+exception <dbapi-exceptions>` and expose the `Error` interface.
.. autofunction:: lookup
programming language.
`!psycopg3` presents a familiar interface for everyone who has used
-`!psycopg2` or any other `DB API 2.0`__ database adapter, but allows to use
+`!psycopg2` or any other `DB-API 2.0`__ database adapter, but allows to use
more modern PostgreSQL and Python features, such as:
- Strict Strong Typing
==================
The basic Psycopg usage is common to all the database adapters implementing
-the `DB API`__ protocol. Other database adapters, such as the builtin
+the `DB-API`__ protocol. Other database adapters, such as the builtin
`sqlite3` or `psycopg2`, have roughly the same pattern of interaction.