我试图使用查询检索dynamodb表中的所有项目.以下是我的代码:
import boto.dynamodb2
from boto.dynamodb2.table import Table
from time import sleep
c = boto.dynamodb2.connect_to_region(aws_access_key_id="XXX",aws_secret_access_key="XXX",region_name="us-west-2")
tab = Table("rip.irc",connection=c)
x = tab.query()
for i in x:
print i
sleep(1)
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误:
ValidationException: ValidationException: 400 Bad Request
{'message': 'Conditions can be of length 1 or 2 only', '__type': 'com.amazon.coral.validate#ValidationException'}
Run Code Online (Sandbox Code Playgroud)
我所拥有的代码非常简单,并且不受boto dynamodb2文档的影响,所以我不确定为什么会出现上述错误.任何见解都将受到赞赏(新的,有点失去).谢谢
编辑:我有一个哈希键和一个范围键.我能够通过特定的哈希键进行查询.例如,
x = tab.query(hash__eq="2014-01-20 05:06:29")
Run Code Online (Sandbox Code Playgroud)
我怎样才能检索所有物品?
我在R中有一个数据帧列表.列表中的所有数据帧都具有相同的大小.但是,元素可以是不同类型的.例如,

我想将一个函数应用于数据框的相应元素.例如,我想使用粘贴函数来生成数据框,例如
"1a" "2b" "3c"
"4d" "5e" "6f"
Run Code Online (Sandbox Code Playgroud)
有没有一种直接的方法在R中执行此操作.我知道可以使用Reduce函数在列表中的数据帧的相应元素上应用函数.但在这种情况下使用Reduce功能似乎没有达到预期的效果.
Reduce(paste,l)
Run Code Online (Sandbox Code Playgroud)
生产:
"c(1, 4) c(\"a\", \"d\")" "c(2, 5) c(\"b\", \"e\")" "c(3, 6) c(\"c\", \"f\")"
Run Code Online (Sandbox Code Playgroud)
想知道我是否可以这样做而不用乱写for循环.任何帮助表示赞赏!
我试图使用boto库将项添加到dynamodb表.这似乎很简单.我的代码是:
import boto.dynamodb
c = boto.dynamodb.connect_to_region(aws_access_key_id="xxx",
aws_secret_access_key="xxx",
region_name="us-west-2")
users = c.get_table("users")
users.put_item(data={'username': 'johndoe',
'first_name': 'John',
'last_name': 'Doe'})
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误:
'Table' object has no attribute 'put_item'
Run Code Online (Sandbox Code Playgroud)
我认为我连接到数据库很好,并得到了users表(users变量是类型:) boto.dynamodb.table.Table.所以,我不确定为什么它找不到put_item方法(我甚至检查Table了boto库中类的代码,它有put_item方法).任何见解都将受到高度赞赏.