]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
docs: document PGconn needs_password and used_password attributes
authorDenis Laxalde <denis@laxalde.org>
Sat, 19 Mar 2022 08:46:58 +0000 (09:46 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 19 Mar 2022 15:03:24 +0000 (16:03 +0100)
This improves the documentation of Error class, which refers to those
in the new pgconn attribute documentation.

docs/api/errors.rst
docs/api/pq.rst
psycopg/psycopg/pq/pq_ctypes.py

index 6d810d39aabe569759ac92fa68943d417df360ac..3f0a719bb3f5505c7ca720f99e1b8f1e3608ff07 100644 (file)
@@ -53,7 +53,7 @@ These classes are exposed both by this module and the root `psycopg` module.
         Most likely it will be in `~psycopg.pq.ConnStatus.BAD` state;
         however it might be useful to verify precisely what went wrong, for
         instance checking the `~psycopg.pq.PGconn.needs_password` and
-        `~psycopg.pq.PGconn.used_password`.
+        `~psycopg.pq.PGconn.used_password` attributes.
 
         .. versionadded:: 3.1
 
index 6cd77cbe64581aa9145dc2a5cc181d0d94b5d088..3d259598a5cc4633d7a4579c6da35ee19a1a2e10 100644 (file)
@@ -88,6 +88,8 @@ Objects wrapping libpq structures and functions
 
     .. autoattribute:: pgconn_ptr
     .. automethod:: get_cancel
+    .. autoattribute:: needs_password
+    .. autoattribute:: used_password
 
 
 .. autoclass:: PGresult()
index f286b7ec82b789da7355fc1ac99a3060993b19d5..a8acc3d85f62067dbc814881ffc884b2c3125cd1 100644 (file)
@@ -240,10 +240,19 @@ class PGconn:
 
     @property
     def needs_password(self) -> bool:
+        """True if the connection authentication method required a password,
+        but none was available.
+
+        See :pq:`PQconnectionNeedsPassword` for details.
+        """
         return bool(impl.PQconnectionNeedsPassword(self._pgconn_ptr))
 
     @property
     def used_password(self) -> bool:
+        """True if the connection authentication method used a password.
+
+        See :pq:`PQconnectionUsedPassword` for details.
+        """
         return bool(impl.PQconnectionUsedPassword(self._pgconn_ptr))
 
     @property