Skip to content

Instantly share code, notes, and snippets.

@hattorix
Last active December 10, 2015 05:29
Show Gist options
  • Save hattorix/4388082 to your computer and use it in GitHub Desktop.
Save hattorix/4388082 to your computer and use it in GitHub Desktop.
AzureTable のクエリ全行取得
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