aws.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:donatemates 作者: donatemates 项目源码 文件源码
def increment_attribute(self, key_dict, attribute_name, increment_value):
        """Method to increment a single attribute in a record

        Args:
            key_dict (dict): A dictionary containing the keys/values to query on. Supports simple and compound keys
            attribute_name (str): The attribute to increment
            increment_value (int): The amount to increment the attribute by

        Returns:
            None
        """
        response = self.table.update_item(Key=key_dict,
                                          UpdateExpression="SET {} = {} + :increment".format(attribute_name,
                                                                                             attribute_name),
                                          ExpressionAttributeValues={':increment': increment_value},
                                          ReturnValues="UPDATED_NEW")


        if response['ResponseMetadata']['HTTPStatusCode'] != 200:
            raise Exception("Error getting item: {}".format(response['ResponseMetadata']))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号