Fetch tasks from the database