python C boto dynamodb2:我可以只使用范围键查询表吗?
发布时间:2023-12-16 23:30:28 所属栏目:Python 来源:DaWei
导读: 在我的一个
python应用程序中,我正在使用boto,我想只使用范围键查询dynamodb表.我不想使用扫描.
评级表的模式
ratings = Table.create('ratings',schema=[
HashKey('user_i
python应用程序中,我正在使用boto,我想只使用范围键查询dynamodb表.我不想使用扫描.
评级表的模式
ratings = Table.create('ratings',schema=[
HashKey('user_i
在我的一个 python应用程序中,我正在使用boto,我想只使用范围键查询dynamodb表.我不想使用扫描. 评级表的模式 ratings = Table.create('ratings',schema=[ HashKey('user_id',data_type=NUMBER),RangeKey('photo_id',data_type=NUMBER) ],throughput={ 'read': 5,'write': 15,},indexes = [ AllIndex('rating_allindex',parts=[ HashKey('user_id',data_type=NUMBER) ]) ]) from boto.dynamodb2.table import Table ratings = Table('ratings') # photo_id is range_key and user_id is hash_key ratings_list = ratings.query(photo_id__eq=1)这样做,我得到此错误查询条件错过了关键架构元素user_id. 但它显示错误,不支持查询键条件.我想只有hash_key允许使用过滤器__eq.我如何实现我想要的目标? 解决方法 在DynamoDB上使用 Query操作时,必须提供一个哈希键,它没有被定义为range_key_conditions的一部分,正如您在文档中看到的那样 C 因此您必须使用已经找到的user_id_eq.如果需要在一次API调用中从多个哈希键中获取行,则必须使用“扫描”(可以使用batchGet获取多行,但这与您的方案无关) P.s,看来你的二级索引与Range键相同,那是一个错误吗? (编辑:百色站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- python – 最终确保一些代码以原子方式运行,无论如何?
- python – 使用pandas返回hdf文件中所有数据集的列表
- 在Python中将数组转换为DataFrame
- python – 如何将二进制转换为浮点数
- Pythonic计算pandas数据帧条纹的方法
- django – Travis:“创建测试数据库时出错:创建数据库的权
- python – tkinter中的标签宽度
- `with canvas:`(Python`with something()as x:`)如何隐式
- 嵌套函数中的python变量范围
- python – 为什么skimage.transform.rotate比PIL的Image.ro
推荐文章
站长推荐