Retrieve tasks from the database