1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
`!abc` -- Psycopg abstract classes
==================================
The module exposes Psycopg definitions which can be used for static type
checking.
.. module:: psycopg.abc
.. seealso::
:ref:`adapt-life-cycle` for more information about how these objects
are used by Psycopg,
.. autoclass:: Dumper(cls, context=None)
This class is a formal `~typing.Protocol`. A partial implementation of
this protocol (implementing everything except the `dump()` metood) is
available as `psycopg.adapt.Dumper`.
:param cls: The type that will be managed by this dumper.
:type cls: type
:param context: The context where the transformation is performed. If not
specified the conversion might be inaccurate, for instance it will not
be possible to know the connection encoding or the server date format.
:type context: `AdaptContext` or None
.. autoattribute:: format
.. automethod:: dump
The format returned by dump shouldn't contain quotes or escaped
values.
.. versionchanged:: 3.2
`!dump()` can also return `!None`, to represent a :sql:`NULL` in
the database.
.. automethod:: quote
.. tip::
This method will be used by `~psycopg.sql.Literal` to convert a
value client-side.
This method only makes sense for text dumpers; the result of calling
it on a binary dumper is undefined. It might scratch your car, or burn
your cake. Don't tell me I didn't warn you.
.. autoattribute:: oid
If the OID is not specified, PostgreSQL will try to infer the type
from the context, but this may fail in some contexts and may require a
cast (e.g. specifying :samp:`%s::{type}` for its placeholder).
You can use the `psycopg.adapters`\ ``.``\
`~psycopg.adapt.AdaptersMap.types` registry to find the OID of builtin
types, and you can use `~psycopg.types.TypeInfo` to extend the
registry to custom types.
.. automethod:: get_key
.. automethod:: upgrade
.. autoclass:: Loader(oid, context=None)
This class is a formal `~typing.Protocol`. A partial implementation of this
protocol (implementing everything except the `load()` method) is available
as `psycopg.adapt.Loader`.
:param oid: The type that will be managed by this dumper.
:type oid: int
:param context: The context where the transformation is performed. If not
specified the conversion might be inaccurate, for instance it will not
be possible to know the connection encoding or the server date format.
:type context: `AdaptContext` or None
.. autoattribute:: format
.. automethod:: load
.. autoclass:: AdaptContext
:members:
.. seealso:: :ref:`adaptation` for an explanation about how contexts are
connected.
|