python查询天蓝色表的所有行 [英] python querying all rows of azure table
问题描述
我的azure表中有大约20000行.我想查询azure表中的所有行.但是由于某些天蓝色的限制,我只能得到1000行.
I have around 20000 rows in my azure table . I wanted to query all the rows in the azure table . But due to certain azure limitation i am getting only 1000 rows.
我的代码
from azure.storage import TableService
table_service = TableService(account_name='xxx', account_key='YYY')
i=0
tasks=table_service.query_entities('ValidOutputTable',"PartitionKey eq 'tasksSeattle'")
for task in tasks:
i+=1
print task.RowKey,task.DomainUrl,task.Status
print i
我想从有效输出表中获取所有行.有没有办法
I want to get all the rows from the validoutputtable .Is there a way to do so
推荐答案
但是由于某些天蓝色的限制,我只能得到1000行.
But due to certain azure limitation i am getting only 1000 rows.
这是已记录的限制.对Azure表的每个查询请求将返回不超过1000行.如果有1000个以上的实体,表服务将返回一个延续令牌,必须使用该令牌来获取下一组实体(请参见此处的备注"部分:
This is a documented limitation. Each query request to Azure Table will return no more than 1000 rows. If there are more than 1000 entities, table service will return a continuation token that must be used to fetch next set of entities (See Remarks section here: http://msdn.microsoft.com/en-us/library/azure/dd179421.aspx)
请参阅示例代码以从表中获取所有实体:
Please see the sample code to fetch all entities from a table:
from azure import *
from azure.storage import TableService
table_service = TableService(account_name='xxx', account_key='yyy')
i=0
next_pk = None
next_rk = None
while True:
entities=table_service.query_entities('Address',"PartitionKey eq 'Address'", next_partition_key = next_pk, next_row_key = next_rk, top=1000)
i+=1
for entity in entities:
print(entity.AddressLine1)
if hasattr(entities, 'x_ms_continuation'):
x_ms_continuation = getattr(entities, 'x_ms_continuation')
next_pk = x_ms_continuation['nextpartitionkey']
next_rk = x_ms_continuation['nextrowkey']
else:
break;
这篇关于python查询天蓝色表的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!