我正在使用boto訪問dynamodb表。直到我嘗試執行掃描操作時,一切進展順利。無法通過boto使用dynamodb掃描
我試過一對夫婦,我發現互聯網經過反覆搜索語法,但沒有運氣:
def scanAssets(self, asset):
results = self.table.scan({('asset', 'EQ', asset)})
-or-
results = self.table.scan(scan_filter={'asset':boto.dynamodb.condition.EQ(asset)})
我掃描被稱爲「資產」的屬性,以及資產是一個字符串。
奇怪的是table.scan呼叫最終總是通過此功能會:
def dynamize_scan_filter(self, scan_filter):
"""
Convert a layer2 scan_filter parameter into the
structure required by Layer1.
"""
d = None
if scan_filter:
d = {}
for attr_name in scan_filter:
condition = scan_filter[attr_name]
d[attr_name] = condition.to_dict()
return d
我不是一個Python的專家,但我看不出如何做到這一點的工作。即scan_filter必須通過此代碼的結構是什麼樣的?
同樣,也許我只是把它說錯了。有什麼建議麼?
嗨吉姆·鮑德溫,歡迎堆棧溢出。在這個網站[它可以回答你自己的問題](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/)。所以,不要編輯你的問題帖子,你可以把答案放在回答帖子中並接受它(通過勾選答案左側的複選標記)? – Sicco