def delete(task_id):
	'''
	Delete a task from the database
		arg: task_id - the id of the task to delete
	'''

	Tasks.delete(task_id)
	return '{"status": "success"}'
Esempio n. 2
0
 def tearDown(self):
     """Clear test_db (Delete all row in tasks table)"""
     app.engine = create_engine(
         "mysql+pymysql://{user}:{password}@{host}/{db}".format(
             user=app.config.DB_USER,
             db=app.config.DB_NAME,
             host=app.config.DB_HOST,
             password=app.config.DB_PASSWORD))
     with app.engine.connect() as conn:
         conn.execute(Tasks.delete())
Esempio n. 3
0
async def delete_task(request, task_id):
    errors = ''
    status_code = 202
    async with app.engine.acquire() as conn:
        query = await conn.execute(Tasks.select().where(Tasks.c.id == task_id))
        task = await query.fetchone()
        if task:
            await conn.execute(Tasks.delete().where(Tasks.c.id == task_id))
            await conn.connection.commit()
        else:
            status_code = 404
            errors = 'Not Found'
    return response.json({'errors': errors}, status_code)