From 6b3e8fe041b35d4630af9d95245674416db663fb Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Tue, 4 Oct 2022 10:18:27 -0700 Subject: [PATCH] Show an example of a custom Record class This demonstrates a dot-notation implementation as suggested by this FAQ item. --- docs/faq.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/faq.rst b/docs/faq.rst index 664e49bd..52e5f9e3 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -34,6 +34,12 @@ class that implements dot-notation via the ``record_class`` argument to :func:`connect() ` or any of the Record-returning methods. +.. code-block:: python + + class MyRecord(asyncpg.Record): + def __getattr__(self, name): + return self[name] + Why can't I use a :ref:`cursor ` outside of a transaction? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~