def db_get_task(list_id, task_id): ''' Queries the db for a task with the specified id''' query = ''' SELECT * FROM Tasks WHERE (id = ? AND list = ?) ORDER BY ASC ''' with app.app_context(): cur = get_db().cursor() cur.execute(query, [task_id, list_id]) task = Task.fromDict(dict_from_row(cur.fetchone())) return task
def db_get_task(list_id, task_id): ''' Queries the db for a task with the specified id''' query = ''' select * from Tasks where id = ? and list = ? order by id asc ''' with app.app_context(): cur = get_db().cursor() cur.execute(query, [task_id, list_id]) task = Task.fromDict(dict_from_row(cur.fetchone())) return task
def db_get_task(list_id, task_id): ''' Queries the db for a task with the specified id''' query = ''' SELECT id, title, list, status, description, due, revision FROM tasks WHERE id = ? AND list = ?; ''' with app.app_context(): cur = get_db().cursor() cur.execute(query, [task_id, list_id]) task = Task.fromDict(dict_from_row(cur.fetchone())) return task
def db_get_tasks_for_list(list_id): ''' Returns all tasks from the database for a given list''' query = ''' SELECT * FROM Tasks WHERE list = ? ''' with app.app_context(): cur = get_db().cursor() cur.execute(query, [list_id]) tasks = [] for row in cur: task = Task.fromDict(dict_from_row(row)) if isinstance(task, Task): tasks.append(task) return tasks