- configure a composite type adaptation using `register()`
"""
+ __module__ = "psycopg3.types"
+
def __init__(
self,
name: str,
def fetch(
cls: Type[T], conn: "Connection", name: Union[str, "Identifier"]
) -> Optional[T]:
+ """
+ Query a system catalog to read information about a type.
+
+ :param conn: the connection to query
+ :param name: the name of the type to query. It can include a schema
+ name.
+ :return: a `!TypeInfo` object populated with the type information,
+ `!None` if not found.
+ """
from .sql import Composable
if isinstance(name, Composable):
async def fetch_async(
cls: Type[T], conn: "AsyncConnection", name: Union[str, "Identifier"]
) -> Optional[T]:
+ """
+ Query a system catalog to read information about a type.
+
+ Similar to `fetch()` but can use an asynchronous connection.
+ """
from .sql import Composable
if isinstance(name, Composable):
self,
context: Optional["AdaptContext"] = None,
) -> None:
-
+ """
+ Register the type information, globally or in the specified *context*.
+ """
if context:
types = context.adapters.types
else:
class RangeInfo(TypeInfo):
"""Manage information about a range type."""
+ __module__ = "psycopg3.types"
+
def __init__(self, name: str, oid: int, array_oid: int, subtype_oid: int):
super().__init__(name, oid, array_oid)
self.subtype_oid = subtype_oid
class CompositeInfo(TypeInfo):
"""Manage information about a composite type."""
+ __module__ = "psycopg3.types"
+
def __init__(
self,
name: str,
from ._enums import Format as Format
from .oids import postgres_types
from .proto import AdaptContext, Buffer as Buffer
-from .typeinfo import TypesRegistry
+from ._typeinfo import TypesRegistry
if TYPE_CHECKING:
from .connection import BaseConnection
# Copyright (C) 2020-2021 The Psycopg Team
-from .typeinfo import TypeInfo, RangeInfo, TypesRegistry
+from ._typeinfo import TypeInfo, RangeInfo, TypesRegistry
# Global objects with PostgreSQL builtins and globally registered user types.
postgres_types = TypesRegistry()
from ..adapt import Buffer, Dumper, Loader, Transformer
from ..adapt import Format as Pg3Format
from ..proto import AdaptContext
-from ..typeinfo import TypeInfo
+from .._typeinfo import TypeInfo
class BaseListDumper(Dumper):
from ..oids import TEXT_OID
from ..adapt import Buffer, Format, Dumper, Loader, Transformer
from ..proto import AdaptContext
-from ..typeinfo import CompositeInfo
+from .._typeinfo import CompositeInfo
class SequenceDumper(Dumper):
from ..oids import postgres_types as builtins, INVALID_OID
from ..adapt import Buffer, Dumper, Format as Pg3Format
from ..proto import AdaptContext
-from ..typeinfo import RangeInfo
+from .._typeinfo import RangeInfo
from .composite import SequenceDumper, BaseCompositeLoader