Reputation: 3738
The Azure python API while simple and awesome lacks a bit of docu.
im using the the TableService to get an entity, as such
entity = self._tableService.get_entity(tableName, partitionKey, rowKey)
What is the returned entity?
the following blows up
for key in entity.keys():
Further is this an array of above entities
entities = self._tableService.query_entities(tableName, query)
Upvotes: 2
Views: 3039
Reputation: 96
get_entity will return an instance of azure.storage.Entity with fields such as PartitionKey, RowKey and all the other fields that you've set when you added it to the table.
query_entities will return a list of azure.storage.Entity
You can add to the table 2 different ways, using a dict:
task = {'PartitionKey': 'tasksSeattle', 'RowKey': '1', 'description' : 'Take out the trash', 'priority' : 200}
table_service.insert_entity('tasktable', task)
or an azure.storage.Entity instance
task = Entity()
task.PartitionKey = 'tasksSeattle'
task.RowKey = '2'
task.description = 'Wash the car'
task.priority = 100
table_service.insert_entity('tasktable', task)
Then get_entity like this:
task = table_service.get_entity('tasktable', 'tasksSeattle', '1')
print(task.PartitionKey)
print(task.RowKey)
print(task.description)
print(task.priority)
Then query_entities like this:
tasks = table_service.query_entities('tasktable', "PartitionKey eq 'tasksSeattle'")
for task in tasks:
print(task.PartitionKey)
print(task.RowKey)
print(task.description)
print(task.priority)
There's a how-to guide that describes the basics: http://www.windowsazure.com/en-us/develop/python/how-to-guides/table-service/
And for more advanced usage, I recommend looking at the unit tests: https://github.com/WindowsAzure/azure-sdk-for-python/blob/master/tests/test_tableservice.py
Upvotes: 1