:members:
-.. data:: psycopg.adapters
-
- The global, default adapters map establishing how Python and PostgreSQL
- types are converted into each other. This map is used as template when new
- connections are created, using `psycopg.connect()`.
-
- :type: `~psycopg.adapt.AdaptersMap`
-
-
.. autoclass:: AdaptersMap
.. automethod:: register_dumper
\|__ `ProgrammingError`
\|__ `NotSupportedError`
-These classes are also exposed both by the Psycopg and the
-`!psycopg.errors` module.
+These classes are exposed both by the Psycopg and the `!psycopg.errors`
+module.
.. autoexception:: Warning()
.. autoexception:: InterfaceError()
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 `~Diagnostic.sqlstate` attribute of
-`Error.diag`).
+called SQLSTATE (available in the `~Diagnostic.sqlstate` attribute of the
+error's `~psycopg.Error.diag` attribute).
Psycopg exposes a different class for each SQLSTATE value, allowing to
write idiomatic error handling code according to specific conditions happening
Every class in the module is named after what referred as "condition name" `in
the documentation`__, converted to CamelCase: e.g. the error 22012,
``division_by_zero`` is exposed by this module as the class `!DivisionByZero`.
-There is a handful of exception, required for disambiguate clashes: please
-refer to the table below for all the classes defined.
+There is a handful of... exceptions to this rule, required for disambiguate
+name clashes: please refer to the table below for all the classes defined.
.. __: https://www.postgresql.org/docs/current/errcodes-appendix.html#ERRCODES-TABLE
:maxdepth: 2
:caption: Contents:
+ module
connections
cursors
sql
errors
+ pool
adapt
types
abc
- pool
pq
--- /dev/null
+The `!psycopg` module
+=====================
+
+Psycopg implements the `Python Database DB API 2.0 specification`__. As such
+it also exposes the `module-level objects`__ required by the specifications.
+
+.. __: https://www.python.org/dev/peps/pep-0249/
+.. __: https://www.python.org/dev/peps/pep-0249/#module-interface
+
+
+.. currentmodule:: psycopg
+
+.. autofunction:: connect
+
+ This is an alias of the class method `Connection.connect`: see its
+ documentation for details.
+
+ If you need an asynchronous connection use `AsyncConnection.connect`
+ instead.
+
+
+.. rubric:: Exceptions
+
+The standard `DBAPI exceptions`__ are exposed both by the `!psycopg` module
+and by the `psycopg.errors` module. The latter also exposes more specific
+exceptions, mapping to the database error states (see
+:ref:`sqlstate-exceptions`.
+
+.. __: https://www.python.org/dev/peps/pep-0249/#exceptions
+
+.. parsed-literal::
+
+ `!Exception`
+ \|__ `Warning`
+ \|__ `Error`
+ \|__ `InterfaceError`
+ \|__ `DatabaseError`
+ \|__ `DataError`
+ \|__ `OperationalError`
+ \|__ `IntegrityError`
+ \|__ `InternalError`
+ \|__ `ProgrammingError`
+ \|__ `NotSupportedError`
+
+
+.. data:: adapters
+
+ The global, default adapters map establishing how Python and PostgreSQL
+ types are converted into each other. This map is used as template when new
+ connections are created, using `psycopg.connect()`.
+
+ :type: `~psycopg.adapt.AdaptersMap`