summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--topics/maybe-monad.gmi5
1 files changed, 3 insertions, 2 deletions
diff --git a/topics/maybe-monad.gmi b/topics/maybe-monad.gmi
index dc3e0b7..b748ad5 100644
--- a/topics/maybe-monad.gmi
+++ b/topics/maybe-monad.gmi
@@ -45,8 +45,9 @@ with conn.cursor(MySQLdb.cursors.DictCursor) as cursor:
```
But, with sql_query_mdict, the row object is a MonadictDict where all values are monadic. We therefore do not need any special conditional checks.
```
-for row in sql_query_mdict("SELECT foo FROM bar"):
- row["foo"].bind(print)
+with database_connection() as conn
+ for row in sql_query_mdict(conn, "SELECT foo FROM bar"):
+ row["foo"].bind(print)
```
As a bonus, sql_query_mdict also gets rid of cursors by returning a generator and letting us iterate over it pythonically.