<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_instance(self, data):
 """Update a single record by id with the provided data. Args: data (dict):
 The new data to update the record with. Returns: self: This is an instance of itself with the updated data. Raises: AttributeError: This is raised if a key in the ``data`` isn't a field on the model. """

        for key, val in iteritems(data):
            if not hasattr(self, key):
                raise AttributeError(
                    "No field named {key} for model {model}".format(
                        key=key,
                        model=self.__class__.__name__
                    )
                )

            setattr(self, key, val)

        self.save()

        return self