Exemple #1
0
def delete_task(task):
    ''' delete a new task '''
    print("I am in delete route" + task)
    db = DaBa("todo")
    # note: the following string interpolation happens in SQL, not in Python
    db.que("DELETE FROM todo WHERE id={taskid}".format(taskid=task))
    db.close()
Exemple #2
0
def db_get_task(id):
    """ retrieves record with id """
    db = DaBa("todo")
    query = "SELECT * FROM todo WHERE id={taskid}".format(taskid=id)
    db.que("SELECT * FROM todo WHERE id={taskid}".format(taskid=id))
    result = db.one()
    db.close()

    return result
def db_get_task(id):
    ''' retrieves record with id '''
    db = DaBa("todo")
    query = "SELECT * FROM todo WHERE id={taskid}".format(taskid=id)
    print("in db_get_task, query: ")
    print(query)
    db.que("SELECT * FROM todo WHERE id={taskid}".format(taskid=id))
    result = db.one()
    db.close()
    return result
Exemple #4
0
def delete():
    # decode json message body into Python dictionary
    task_data = unpack_task(request)
    print("")
    print("in delete() ")
    print(task_data)
    print("")

    db = DaBa("todo")
    db.que("DELETE from todo WHERE id=?", (task_data, ))
    db.close()

    return {}
Exemple #5
0
def db_delete_task(taskid):
    # connect to todo.db
    db = DaBa("todo")
    # construct query to retrieve rows from todo table
    query = "DELETE FROM todo WHERE id = {id}"
    query = query.format(id=taskid)
    # execute query
    print("Query: " + query)
    db.que(query)
    result = db.new_id()
    # close db to release lock on database
    db.close()
    return result
Exemple #6
0
def edit():
    # decode json message body into Python dictionary
    task_data = unpack_task(request)
    print("")
    print("in edit() ")
    print(task_data)
    print("")

    db = DaBa("todo")
    db.que("UPDATE todo SET task = ?, status = ? WHERE id LIKE ?",
           (task, status, id))
    db.close()

    return {'taskid': taskid}
Exemple #7
0
def db_update_task(task):
    ''' update status for task with id '''
    db = DaBa("todo")
    # note: the following string interpolation happens in SQL, not in Python
    print(task)
    id = task['taskID']
    taskD = task['taskdescription']
    taskDD = task['taskduedate']
    taskS = task['status']
    db.que(
        """UPDATE todo 
               SET task = ?,
               duedate = ?,
               status = ?
               WHERE id LIKE ?""", (taskD, taskDD, taskS, id))
    db.close()
Exemple #8
0
def db_create_task(new_task):
    ''' stores new record in db
        returns new record id
    '''
    # connect to todo.db
    db = DaBa("todo")
    # construct query to retrieve rows from todo table
    query = "INSERT INTO todo (task, status) Values('{td}', {status})"
    query = query.format(td=new_task[0], status=(new_task[1]))
    # execute query
    print("Query: " + query)
    db.que(query)
    result = db.new_id()
    # close db to release lock on database
    db.close()
    return result
Exemple #9
0
def db_create_task(a_new_task):
    """ stores new record in db
        returns new record id
    """
    # connect to todo.db
    db = DaBa("todo")
    # construct query to retrieve rows from todo table
    query = "INSERT INTO todo (task, status) VALUES('{td}', '{status}')"
    query = query.format(td=a_new_task[0], status=(a_new_task[1]))
    # execute query
    db.que(query)
    result = db.new_id()
    # close db to release lock on database
    db.close()

    return result
Exemple #10
0
def db_update_task(a_new_task):
    """ stores new record in db
        returns new record id
    """
    # connect to todo.db
    db = DaBa("todo")
    # construct query to retrieve rows from todo table
    query = "UPDATE todo SET task = '{}', status = '{}' WHERE id = '{}'".format(
        a_new_task[1], a_new_task[2], a_new_task[0])
    # execute query
    db.que(query)
    result = a_new_task[0]
    # close db to release lock on database
    db.close()

    return result
Exemple #11
0
def db_delete_task(a_new_task):
    """ stores new record in db
        returns new record id
    """
    # connect to todo.db
    db = DaBa("todo")
    # construct query to retrieve rows from todo table
    query = "DELETE FROM todo WHERE id='{task_id}'".format(
        task_id=a_new_task[0])
    # execute query
    db.que(query)
    result = db.new_id()
    # close db to release lock on database
    db.close()

    return result
def db_get_tasks_by_status(filter):
    ''' retrieve tasks that pass filter '''
    # connect to todo.db
    db = DaBa("todo")
    # construct query to retrieve rows from todo table
    query = "SELECT id, task, status, post_date, due_date FROM todo "

    if filter == 0:
        query += "WHERE status=0"
    elif filter == 1:
        query += "WHERE status=1"
    else:  # filter == "all"
        pass
    # execute query
    db.que(query)
    # retrieve query result as Python sequence of tuples
    result = db.all()
    # close db (otherwise db locked upon future access)
    db.close()
    return result
def db_update_status(id, status):
    ''' update status for task with id '''
    db = DaBa("todo")
    # note: the following string interpolation happens in SQL, not in Python
    db.que("UPDATE todo SET status = ? WHERE id LIKE ?", (status, id))
    db.close()
def db_update_task(id, taskdescription, status, post_date, due_date):
    db = DaBa("todo")
    db.que(
        "UPDATE todo SET task = ?, status = ?, post_date = ?, due_date = ? WHERE id = ?",
        (taskdescription, status, post_date, due_date, id))
    db.close()
def db_delete_task(id):
    ''' delete record by id '''
    db = DaBa("todo")
    db.que("DELETE FROM todo WHERE id = ?", (id, ))
    db.close()
Exemple #16
0
def db_delete_task(id):
    ''' delete id '''
    db = DaBa("todo")
    db.que("DELETE FROM todo WHERE id LIKE ?", (id, ))
    db.close()
Exemple #17
0
def db_delete_task(id):
    db = DaBa("todo")
    db.que("DELETE FROM todo WHERE id={taskid}".format(taskid=id))
    db.close()
Exemple #18
0
def db_update_desc(id, desc):
    ''' update description for task with id '''
    db = DaBa("todo")
    # note: the following string interpolation happens in SQL, not in Python
    db.que("UPDATE todo SET task = ? WHERE id LIKE ?", (desc, id))
    db.close()