Last active
December 10, 2015 05:29
-
-
Save hattorix/4388082 to your computer and use it in GitHub Desktop.
AzureTable のクエリ全行取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.storage import TableService | |
def query_all(account_name, account_key, table_name, query): | |
nextpartitionkey = None | |
nextrowkey = None | |
ts = TableService(account_name, account_key) | |
while True: | |
rows = ts.query_entities(table_name, query, next_partition_key=nextpartitionkey, next_row_key=nextrowkey) | |
for entity in rows: | |
# 行単位の処理を行う | |
print entity.PartitionKey | |
# paging | |
if hasattr(rows, 'x_ms_continuation'): | |
nextpartitionkey = rows.x_ms_continuation['nextpartitionkey'] | |
nextrowkey = rows.x_ms_continuation['nextrowkey'] | |
else: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment