我想使用Python從Microsoft Azure查詢表存儲。我一直在使用這個庫:https://pypi.python.org/pypi/azure-storage/0.20.3Python - 如何獲取Azure延續性令牌?
查詢表存儲並不是太困難,但我不能爲我的生活弄清楚如何獲取連續令牌。我已經看到了幾個C#示例,甚至是一個Java示例,但不是Python的一個示例。
這是我使用'top'參數抓取一千個條目的方法。在這種情況下,我應該在回覆中留下一個延續標記。每本手冊: https://msdn.microsoft.com/en-us/library/azure/dd135718.aspx
def get_thousand_chunk(self, filter, select, top, next_partition_key, next_row_key):
print "Getting table storage..."
list = self.table_service.query_entities(self.table_name, top=1000)
#result.x_ms_continuation['NextPartitionKey']
'''
---LIBRARY DOCUMENTATION WITHIN query_entities METHOD---
Get entities in a table; includes the $filter and $select options.
table_name:
Table to query.
filter:
Optional. Filter as described at
http://msdn.microsoft.com/en-us/library/windowsazure/dd894031.aspx
select:
Optional. Property names to select from the entities.
top:
Optional. Maximum number of entities to return.
next_partition_key:
Optional. When top is used, the next partition key is stored in
result.x_ms_continuation['NextPartitionKey']
next_row_key:
Optional. When top is used, the next partition key is stored in
result.x_ms_continuation['NextRowKey']
'''
print "Got table storage"
return self._mapper(list)
顯然這個代碼是一項正在進行的工作,所以我已經top=1000
硬編碼在方法調用用於測試的參數。我也意識到我目前沒有使用next_partition_key
或next_row_key
但是,我願意接受所有建設性的批評。
如果您需要更多信息才能正確回答,請讓我知道。
謝謝大家提前。
我正在使用Python 2.7.8。
這就是答案。謝謝! – john14073
查看測試以及(https://github.com/Azure/azure-storage-python/blob/master/tests/test_storage_table.py#L638)。另外要注意的是:我們正在對這個庫進行重大重構,即將推出的版本會自動(並且懶洋洋地)遵循繼續令牌。 :) –