简体   繁体   English

无法将项目添加到新的 DynamoDB 表

[英]Cannot add an item to a new DynamoDB table

I need to move an item from one DynamoDb table to another DynamoDB table.我需要将一个项目从一个 DynamoDb 表移动到另一个 DynamoDB 表。 When I use the put_item () function I get an error: <class 'AttributeError'> Object 'dynamodb.ServiceResource' does not have attribute 'put_item'当我使用put_item ()函数时出现错误: <class 'AttributeError'> Object 'dynamodb.ServiceResource' does not have attribute 'put_item'

table = dynamodb.Table ('table1')
newTable = dynamodb.Table('table2')

It's the connection to my tables - the connection is successful I read an item from Table 1 and put data in and sent it to the following function:这是到我的表的连接 - 连接成功我从表 1 中读取了一个项目并将数据放入并将其发送到以下函数:

    try:
        dynamodb.put_item(newTable,data)
        return data
    except:
        e, p, t = sys.exc_info ()
        print ("test")
        print (e, p)

Instead of dynamodb.put_item(newTable,data) use:代替dynamodb.put_item(newTable,data)使用:

newTable.put_item(data)

In your context, put_item is a method of Table object.在您的上下文中, put_itemTable对象的一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM