diff options
author | Arun Isaac | 2022-09-16 15:41:00 +0530 |
---|---|---|
committer | Arun Isaac | 2022-09-16 15:41:00 +0530 |
commit | b85b886f3dacce3aa2756d3a64a2cb8890ad1eb3 (patch) | |
tree | ee48cb42851accbd6c06d91eb3def22e6cdb5578 /wqflask | |
parent | ee635c900525ceecc7619a9b47ab042e8fb81a50 (diff) | |
download | genenetwork2-b85b886f3dacce3aa2756d3a64a2cb8890ad1eb3.tar.gz |
Add example code to docstring of MonadicDictCursor.
* wqflask/utility/monads.py (MonadicDictCursor): Add example code to
docstring.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/utility/monads.py | 7 |
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()) |