From b85b886f3dacce3aa2756d3a64a2cb8890ad1eb3 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 16 Sep 2022 15:41:00 +0530 Subject: Add example code to docstring of MonadicDictCursor. * wqflask/utility/monads.py (MonadicDictCursor): Add example code to docstring. --- wqflask/utility/monads.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wqflask/utility/monads.py b/wqflask/utility/monads.py index 21d04f36..26225eaa 100644 --- a/wqflask/utility/monads.py +++ b/wqflask/utility/monads.py @@ -115,6 +115,13 @@ class MonadicDictCursor(DictCursor): Monadic version of MySQLdb.cursors.DictCursor that returns a MonadicDict instead of the built-in dictionary. + + Execute a SQL query and retrieve results as MonadicDict + objects. Each row object in the following code is a MonadicDict. + >>> with conn.cursor(MonadicDictCursor) as cursor: + ... cursor.execute("SELECT foo FROM bar") + ... for row in cursor.fetchall(): + ... print(row) """ def fetchone(self): return MonadicDict(super().fetchone()) -- cgit v1.2.3