Question

I'm trying to fetch given number of rows from Azure Storage Table. I can find Java example in here and .Net example in here, both of them use Take method.

But, how about Python? is it missing?

Was it helpful?

Solution 2

Python supports it using ‘top’ instead of ‘take’. You should be able to do something like below:

table_service.query_entities('tasktable', "PartitionKey eq 'tasksSeattle'", 'description', ‘8’) // To get 8 rows.

OTHER TIPS

Azure Table Storage has a new python library in preview release that is available for installation via pip. To install use the following pip command

pip install azure-data-tables

Instead of top, there is the results_per_page keyword argument for list and query entities. For example,

from azure.data.tables import TableClient
table_client = TableClient.from_connection_string(conn_str, "myTableName")
for entity in table_client.list_entities(results_per_page=8):
    print(entity)

For more samples on querying and listing entities, check out the samples in the azure-sdk-for-python repository here.

(FYI, I am a Microsoft employee on the Azure SDK for Python team)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top