Dynamodb boto Table.scan具有AND条件



我想在Table.scan、中添加AND类型的过滤器

例如:

scanneditems = logTable.scan(unitid__eq='dev1',time__gte=condition1 and time__lt=condition2)

我需要时间大于condition1但小于condition2的项,如何在这里添加AND类型的条件?

提前谢谢。

如果您想在同一AttributeName上放置两个条件,那么FilterExpression就是最好的选择。下面是boto 2.34中的一段代码片段,演示了上面的过滤器。

# db in this case represents the boto.dynamodb2.layer1.DynamoDBConnection object
db.scan(<Your Table>, filter_expression="unitid = :a AND time > :b AND time < :c",
        expression_attribute_values={":a" : {"S": "dev1"}, ":b": <condition1>, ":c": <condition2>})

如果你还需要什么,请告诉我,谢谢!

最新更新