You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
447 B
Python
16 lines
447 B
Python
from itertools import groupby
|
|
from app import get_db_connection
|
|
|
|
conn = get_db_connection()
|
|
todos = conn.execute('SELECT i.content, l.title FROM items i JOIN lists l \
|
|
ON i.list_id = l.id ORDER BY l.title;').fetchall()
|
|
|
|
lists = {}
|
|
|
|
for k, g in groupby(todos, key=lambda t: t['title']):
|
|
lists[k] = list(g)
|
|
|
|
for list_, items in lists.items():
|
|
print(list_)
|
|
for item in items:
|
|
print(' ', item['content']) |