insert - 如何使用boto3将嵌套字典插入dynamodb?
问题描述
我们构建了一些嵌套格式的数据,它包含 3 个键。id 包含另一个嵌套字典的时间、id 和其他。我们不知道如何为此创建表,也不知道如何将此类数据插入到该特定表中。我们尝试使用名为 id 的 hashkey 创建一个表,但是当我们使用
dynamodb.batch_write_item(RequestItems={
'table': [{ 'PutRequest': { 'Item':whatweget}}
}]
})
它表明botocore.exceptions.ClientError: An error occurred (Validation
Exception) when calling the BatchWriteItem operation: The prov
ided key element does not match the schema
任何人都可以提供一些帮助吗?
解决方案
您可以在 aws 仪表板上使用 DynamoDB 控制台创建表,您可以通过 dynamodb 文档查看详细说明。
对于嵌套字典,您有多个选项,首先您可以将 id 中的值插入为xm ls 或json ns,因为 dynamodb 将接受它作为字符串,如果您想对表操作有更严格的规则,您可以创建一个id 字段和其他应该嵌套在id字段中的字段,它们不必物理存在于id中
您可以使用多种方式将数据插入到您创建的表中,最简单的是通过 aws dynamoDB 控制台手动添加它们,或者您可以使用 boto3,但您当然必须先有一个表。
推荐阅读
- javascript - 在javascript中加载div之前的图像
- windows - 特定月份和年份的文件
- gurobi - 已安装 gurobi ,导入时不反映
- css - 页面加载动画在加载时闪烁(缩放变化)
- c# - 将 HTTPClient.ReadAsAsync 结果反序列化为对象列表
- c# - “清除”字符串的 ObservableCollection 时数据绑定不刷新
- llvm-clang - 构建 ebpf 时,我得到“未知目标三重 'bpf',请使用 -triple 或 -arch”
- php - 如何使用 codeigniter 在另一台设备上取消设置会话
- android - 图像没有使用 Glide 缓存
- ruby-on-rails - Factorybot 无法识别任何属性——“方法缺失”错误