aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-09-16 15:41:00 +0530
committerArun Isaac2022-09-16 15:41:00 +0530
commitb85b886f3dacce3aa2756d3a64a2cb8890ad1eb3 (patch)
treeee48cb42851accbd6c06d91eb3def22e6cdb5578
parentee635c900525ceecc7619a9b47ab042e8fb81a50 (diff)
downloadgenenetwork2-b85b886f3dacce3aa2756d3a64a2cb8890ad1eb3.tar.gz
Add example code to docstring of MonadicDictCursor.
* wqflask/utility/monads.py (MonadicDictCursor): Add example code to docstring.
-rw-r--r--wqflask/utility/monads.py7
1 files changed, 7 insertions, 0 deletions
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())