Update database row factory to produce a dict of columns

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2023-07-25 16:42:24 -07:00
parent e51dd85d54
commit 84c886693f

View File

@@ -37,6 +37,14 @@ def get_db(db_path: str = DB_PATH):
); );
""" """
) )
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
db.row_factory = dict_factory
return db return db