]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Corrections to the types module docs
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 13 Jul 2021 01:55:05 +0000 (03:55 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 13 Jul 2021 01:55:05 +0000 (03:55 +0200)
docs/api/types.rst
psycopg/psycopg/_typeinfo.py

index bf63d09e64c0e05103891820e5e571b41d810f55..eaf6c8a828abf4973cab49df5f3dc046276171d6 100644 (file)
@@ -20,11 +20,11 @@ type, such as its name, oid and array oid. The class can be used to query a
 database for custom data types: this allows for instance to load automatically
 arrays of a custom type, once a loader for the base type has been registered.
 
-The `!TypeInfo` object doesn't instruct Psycopg to convert a PostgreSQL
-type into a Python type: this is the role of a `Loader`. However it can extend
-the behaviour of the adapters: if you create a loader for `!MyType`, using
-`TypeInfo` you will be able to manage seamlessly arrays of `!MyType` or ranges
-and composite types using it as a subtypes.
+The `!TypeInfo` object doesn't instruct Psycopg to convert a PostgreSQL type
+into a Python type: this is the role of a `~psycopg.abc.Loader`. However it
+can extend the behaviour of the adapters: if you create a loader for
+`!MyType`, using `TypeInfo` you will be able to manage seamlessly arrays of
+`!MyType` or ranges and composite types using it as a subtype.
 
 .. seealso:: :ref:`adaptation` describes about how to convert from Python
     types to PostgreSQL types and back.
@@ -44,7 +44,7 @@ and composite types using it as a subtypes.
         def load(self, data):
             # parse the data and return a MyType instance
 
-    MyTypeLoader.register(conn)
+    conn.adapters.register_loader("mytype", MyTypeLoader)
 
     for record in conn.execute("select mytypearray from mytable"):
         # records will return lists of MyType instances
index 1d9f5c89a18e5173e9102932018a46015e87b798..2a38723cdd463d32ed4a8693c63cc99ef77f5e40 100644 (file)
@@ -63,6 +63,7 @@ class TypeInfo:
         :param conn: the connection to query
         :param name: the name of the type to query. It can include a schema
             name.
+        :type name: `!str` or `~psycopg.sql.Identifier`
         :return: a `!TypeInfo` object populated with the type information,
             `!None` if not found.
         """