def locked_put(self, credentials):
filters = {self.key_name: self.key_value}<EOL>query = self.session.query(self.model_class).filter_by(**filters)<EOL>entity = query.first()<EOL>if not entity:<EOL><INDENT>entity = self.model_class(**filters)<EOL><DEDENT>setattr(entity, self.property_name, credentials)<EOL>self.session.add(entity)<EOL>
Write a credentials to the SQLAlchemy datastore.

        Args:
            credentials: :class:`oauth2client.Credentials`