I am stuck trying to find the right syntax for creating a range query from python to an Azure Table Storage table.
The continuation token cannot help me since I want to define a specific range or RowKeys and retrieve only those.
I have been trying the following
rows = table_service.query_entities(
tableName,
"PartitionKey eq '6' and RowKey gt '1452702466022' and RowKey lt '1452702466422")
and
rows = table_service.query_entities(
'rawpowervalues6', "PartitionKey eq '6'",
select="RowKey gt '1452702466022' and RowKey lt '1452702466422")
With no luck. I cannot find any official documentation regarding python range queries. The best resource so far for that matter is that but I cannot make it work in python.
In your first query, you are missing an ending quote: '
. You might want to try:
rows = table_service.query_entities( \
tableName, \
"((PartitionKey eq '6' and RowKey gt '1452702466022') and RowKey lt '1452702466422')")
Based on my understanding, @minghan said was correct that your first code is right but missing an end-quote '
in the filter
argument. For the second code, the select
argument only select property name for the return entities, but do not code the condition expression like filter
in it.
You can review the definition of the function table_service.query_entites
below from Github https://github.com/Azure/azure-storage-python/blob/master/azure/storage/table/tableservice.py , and combine with the section Supported Comparison Operators
of the reference doc Querying Tables and Entities
def query_entities(self, table_name, filter=None, select=None, top=None,
next_partition_key=None, next_row_key=None):
'''
Get entities in a table; includes the $filter and $select options.
table_name:
Table to query.
filter:
Optional. Filter as described at
http://msdn.microsoft.com/en-us/library/windowsazure/dd894031.aspx
select:
Optional. Property names to select from the entities.
top:
Optional. Maximum number of entities to return.
next_partition_key:
Optional. When top is used, the next partition key is stored in
result.x_ms_continuation['NextPartitionKey']
next_row_key:
Optional. When top is used, the next partition key is stored in
result.x_ms_continuation['NextRowKey']
'''
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.