forked from orbit-oss/flask
Fix doc bug, clarify use of make_dicts
This commit is contained in:
parent
2e17ad7fd4
commit
159ae3dc26
1 changed files with 2 additions and 2 deletions
|
|
@ -72,10 +72,10 @@ Now in each request handling function you can access `g.db` to get the
|
||||||
current open database connection. To simplify working with SQLite, a
|
current open database connection. To simplify working with SQLite, a
|
||||||
row factory function is useful. It is executed for every result returned
|
row factory function is useful. It is executed for every result returned
|
||||||
from the database to convert the result. For instance in order to get
|
from the database to convert the result. For instance in order to get
|
||||||
dictionaries instead of tuples this can be used::
|
dictionaries instead of tuples this could be inserted into ``get_db``::
|
||||||
|
|
||||||
def make_dicts(cursor, row):
|
def make_dicts(cursor, row):
|
||||||
return dict((cur.description[idx][0], value)
|
return dict((cursor.description[idx][0], value)
|
||||||
for idx, value in enumerate(row))
|
for idx, value in enumerate(row))
|
||||||
|
|
||||||
db.row_factory = make_dicts
|
db.row_factory = make_dicts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue