Skip to main content
 首页 » 编程设计

python之Azure 表存储之使用 next_row_key 返回相同的 block

2024年10月24日11webabcd

我正在尝试使用 query_entities 响应中的延续 token 来检索接下来的 1000 个值,但我得到了相同的 1000 个值。

我的代码

rows = table_service.query_entities( 
    'tableName', "PartitionKey eq '6'", top=1000) 
 
nextRowKey = rows.x_ms_continuation['NextRowKey'] 
 
rows = table_service.query_entities( 
    'tableName', "PartitionKey eq '6'", 
    next_row_key=nextRowKey, top=1000) 

我做错了什么吗?来自 github 中的解释它似乎应该工作。

请您参考如下方法:

当表服务返回延续标记时,您会得到两样东西 - NextPartitionKey 和 NextRowKey。要获取下一组实体,您需要同时使用它们。请执行以下操作:

rows = table_service.query_entities( 
    'tableName', "PartitionKey eq '6'", top=1000) 
 
nextRowKey = rows.x_ms_continuation['NextRowKey'] 
nextPartitionKey = rows.x_ms_continuation['NextPartitionKey'] 
 
rows = table_service.query_entities( 
    'tableName', "PartitionKey eq '6'", next_partition_key=nextPartitionKey, 
    next_row_key=nextRowKey, top=1000)