aws.py 文件源码

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

项目:donatemates 作者: donatemates 项目源码 文件源码
def query_hash(self, hash_name, hash_value, index=None, forward=True, limit=None, projection=None):
        """Method to query an index

        Args:
            data (dict): A dictionary of attributes to put

        Returns:
            (dict)
        """
        params = {"ScanIndexForward": forward,
                  "KeyConditionExpression": Key(hash_name).eq(hash_value)}
        if index:
            params["IndexName"] = index
        else:
            # If primary index, consistent read
            params["ConsistentRead"] = True

        if limit:
            params["Limit"] = limit

        if projection:
            params["ProjectionExpression"] = projection

        response = self.table.query(**params)

        if response['ResponseMetadata']['HTTPStatusCode'] != 200:
            raise Exception("Error getting item: {}".format(response['ResponseMetadata']))

        return response["Items"]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号