带有AND条件的Dynamodb boto Table.scan

时间:2014-11-10 06:12:36

标签: boto

我想在Table.scan中添加AND种类的过滤器,

例如:

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

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

提前谢谢你。

1 个答案:

答案 0 :(得分:1)

如果要在同一个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>})

如果您还有其他需要,请告诉我,谢谢!