【问题标题】:Python DynamoDB create custom last_evaluated_key from particular table entryPython DynamoDB 从特定表条目创建自定义 last_evaluate_key
【发布时间】:2017-12-12 16:57:33
【问题描述】:

我们需要创建自定义的最后评估键

用例如下:

第一次扫描表有十条记录,当我进行第二次扫描操作时,第十条记录应该是我最后评估的键

提前致谢

【问题讨论】:

    标签: python-3.x amazon-dynamodb flash-message botocore


    【解决方案1】:
    #Exclusive start key should be null for your first page
    esk = None
    #Get the first page
    scan_generator = MyTable.scan(Limit=10, exclusive_start_key=esk)
    #Get the key for the next page
    esk = scan_generator.kwargs['exclusive_start_key'].values()
    #Now get page 2
    scan_generator = MyTable.scan(Limit=10, exclusive_start_key=esk)
    

    编辑:

    exclusive_start_key (list or tuple) – 从中继续先前查询的项目的主键。这将作为该查询中的 LastEvaluatedKey 提供。

    例如

    exclusive_start_key = ('myhashkey');
    

    exclusive_start_key = ('myhashkey', 'myrangekey');
    

    【讨论】:

    • 感谢您的回复,没有 'max_results' 不工作??
    • 对不起,应该是限制。 Scan docs
    • 任何其他方式生成独占开始密钥
    • 只需使用您要开始的项目的主键创建一个元组。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-10
    • 1970-01-01
    相关资源
    最近更新 更多