python querying all rows of azure table

后端 未结 2 1342
说谎
说谎 2020-12-17 00:51

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.

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-17 01:47

    Update 2019

    Just running for loop on the query result (as author of the topic does) - will get all the data from the query.

    from azure.cosmosdb.table.tableservice import TableService
    
    table_service = TableService(account_name='accont_name', account_key='key')
    
    #counter to keep track of records
    counter=0
    
    # get the rows. Debugger shows the object has only 100 records
    rows = table_service.query_entities(table,"PartitionKey eq 'mykey'")
    
    for row in rows:
        if (counter%100 == 0):
            # just to keep output smaller, print every 100 records
            print("Processing {} record".format(counter))
        counter+=1 
    

    The output proves that loop goes over a 1000 records

    ...
    Processing 363500 record
    Processing 363600 record
    ...
    

提交回复
热议问题