簡體   English   中英

使用Python SDK通過RowKey和StartsWith篩選Azure表存儲

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

我已經看到Azure Table Storage支持通過部分RowKey (除了PartitionKey )查詢記錄( 此處為 C#示例)。

但是,在過濾查詢結果的實際文檔中,我找不到任何與此相關的內容( 此處 )。

我正在嘗試使用Python Azure-Storage SDK查詢PartitionKeyRowKey組合的子集,其中RowKey以某個字符串開頭。 我有代碼(可以,但是不能正確過濾任何行鍵):

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)

但是,我無法弄清楚是否還會向過濾器添加部分( startswith )約束的語法。

有沒有人有通過部分RowKey字符串過濾Azure表存儲查詢的經驗? 我在這里不知所措; 但是,似乎可以通過以上示例中的C#代碼進行操作。

如果有關於如何通過REST調用執行此操作的其他文檔,我可能可以將其轉換為Python用法。

假設您的RowKey值包含單詞,並且您只想過濾以ab開頭的單詞,這就是您要添加到查詢中的內容:

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

因此,您的代碼將類似於:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM