代码之家  ›  专栏  ›  技术社区  ›  Alessandro Dentella

如何在dynamodb中使用boto3扫描滤波器

  •  0
  • Alessandro Dentella  · 技术社区  · 8 年前

    我正试着用boto3用dynamodb测试样品过滤器。我的简单例子-写的几乎与 documented .scan :

    In [24]: list(User.scan())
    Out[24]: [users_info-dev<giovanni>, users_info-dev<nicola>, users_info-dev<ping>]
    

    尝试筛选密钥时:

    User.scan(FilterExpression=Attr('user_id').eq('giovanni'))
    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    ...
    
    ValueError: Attribute FilterExpression specified for filter does not exist.
    
    from boto3.dynamodb.conditions import Key, Attr
    

    错误是什么,执行此扫描的正确方法是什么?

    1 回复  |  直到 8 年前
        1
  •  0
  •   Alessandro Dentella    8 年前

    我没有意识到我在用一个Wrapper围着pynamodb提供的桌子转。这个表不是boto3提供的,而是pynamodb提供的,因此查询/扫描的语法是 different

    User.scan(User.user_id == 'giovanni')