简体   繁体   English

使用Python SDK通过RowKey和StartsWith筛选Azure表存储

[英]Filter Azure Table Storage by RowKey and StartsWith using the Python SDK

I have seen that Azure Table Storage supports querying records by a partial RowKey (in addition to the PartitionKey ) (C# example here ). 我已经看到Azure Table Storage支持通过部分RowKey (除了PartitionKey )查询记录( 此处为 C#示例)。

However, I can't find anything related to this in the actual docs on filtering query results ( here ). 但是,在过滤查询结果的实际文档中,我找不到任何与此相关的内容( 此处 )。

I am trying to using the Python Azure-Storage SDK to query a subset of PartitionKey and RowKey combinations where the RowKey starts with a certain string. 我正在尝试使用Python Azure-Storage SDK查询PartitionKeyRowKey组合的子集,其中RowKey以某个字符串开头。 I have the code (which works, but does not do correct filtering any row keys): 我有代码(可以,但是不能正确过滤任何行键):

from azure.storage.table import TableService
table_service = TableService(account_name=ACCOUNT_NAME, account_key=ACCOUNT_KEY)
entities = table_service.query_entities('mystoragetable', filter='PartitionKey eq mypartitionkey"', num_results=10)

However, I can't figure out the syntax for also adding a partial ( startswith ) constraint to the filter. 但是,我无法弄清楚是否还会向过滤器添加部分( startswith )约束的语法。

Has anyone had any experience with filtering Azure Table Storage queries by partial RowKey strings? 有没有人有通过部分RowKey字符串过滤Azure表存储查询的经验? I am at a loss here; 我在这里不知所措; however, it seems to be possible via the C# code in the example above. 但是,似乎可以通过以上示例中的C#代码进行操作。

If there are any extra docs about how to do this via a REST call, I can probably translate that into the Python usage. 如果有关于如何通过REST调用执行此操作的其他文档,我可能可以将其转换为Python用法。

Assuming your RowKey values contains words and you only want to filter the words starting with a and b , this is what you would add to your query: 假设您的RowKey值包含单词,并且您只想过滤以ab开头的单词,这就是您要添加到查询中的内容:

(RowKey ge 'a' and RowKey lt 'c') ==> (RowKey >= 'a' && RowKey < 'c')

So your code would be something like: 因此,您的代码将类似于:

entities = table_service.query_entities('mystoragetable', filter="PartitionKey eq 'mypartitionkey' and RowKey ge '<starts with substring>'", num_results=10)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Azure 表存储中使用 RowKey 或时间戳检索最新记录 - How to retrieve latest record using RowKey or Timestamp in Azure Table storage 在Azure表存储中分配行键值 - Assigning rowkey values in Azure table storage 更新Azure表存储中的RowKey或PartitionKey - Update RowKey or PartitionKey in Azure Table Storage Azure表存储 - 有序数据的RowKey设计 - Azure Table Storage - RowKey design for ordered data 查询行键大于Azure表存储中的行键 - query rowkey with greater than in azure table storage Azure 存储资源管理器:如何使用“包含”查询表存储 Rowkey? - Azure Storage Explorer: How to query Table Storage Rowkey with “Contains”? Okta SDK筛选具有活动状态并使用StartsWith和Contains关键字的用户 - Okta SDK Filter users with active status and using StartsWith and Contains keywords 当使用无效值查询Azure表存储时,请指定ParitionKey或RowKey错误 - Specify wheter ParitionKey or RowKey is wrong when querying Azure Table Storage with invalid values 如何从 TableOperation 中的 Azure 表存储中检索实体列表而不指定 rowKey? - How to retrieve a list of entities without specifying rowKey from Azure Table Storage in the TableOperation? Azure表存储(Partition key row key),如何在同一个partition不同rowKey对应插入多个实体? - Azure table storage (Partition key row key), how to insert multiple entities in corresponding to same parttion and different rowKey?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM