我在Dynamodb中创建了一个表,其中包含以下详细信息
class OrderStatusIndex(GlobalSecondaryIndex):
class Meta:
index_name = 'OrderStatusIndex'
read_capacity_units = 2
write_capacity_units = 1
projection = AllProjection()
order_status = NumberAttribute(hash_key=True)
created_on = UnicodeAttribute(range_key=True)
class Order(Model):
class Meta:
table_name = 'order'
host = 'http://localhost:8000'
read_capacity_units = 2
write_capacity_units = 1
order_id = NumberAttribute(hash_key=True)
order_status = NumberAttribute(hash_key=True)
created_on = UnicodeAttribute(range_key=True)
order_status_index = OrderStatusIndex()
现在我想根据订单状态来查询,该状态是在特定日期得到的 如果我做mysql查询,如下所示
^{pr2}$在Dynamodb中使用pynamodb也能实现同样的功能吗
试试这个:
指向
pynamodb
API文档的链接:http://pynamodb.readthedocs.io/en/latest/api.html#pynamodb.models.Model.scan
您可以参考以下链接来了解如何对
pynamodb
查询使用条件表达式。在https://pynamodb.readthedocs.io/en/latest/batch.html#query-filters
https://pynamodb.readthedocs.io/en/latest/conditional.html#condition-expressions
希望这有帮助。在
相关问题 更多 >
编程相关推荐