def get_db():
"""
From the Flask Websitei, probs best practice to connect to the databse this way
"""
db = getattr(g, '_database', None)
if db is None:
db = g._database = sqlite3.connect(dbpath)
def make_dicts(cursor, row):
return dict((cursor.description[idx][0], value)
for idx, value in enumerate(row))
db.row_factory = make_dicts
return db
评论列表
文章目录