[英]How to transfer data from one table to another (DynamoDB on AWS)
How do I transfer data from one table to another in DynamoDB?如何在 DynamoDB 中将数据从一个表传输到另一个表? I'm confused because tables and table-fields look absolutely identical.
我很困惑,因为表和表字段看起来完全相同。
To copy a source table to a new destination table, then on Demand Backup and restore should do the trick.要将源表复制到新的目标表,然后按需备份和还原应该可以解决问题。 Details are here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/backuprestore_HowItWorks.html
详细信息在这里: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/backuprestore_HowItWorks.html
If you are looking to copy the data from a source DDB table to an EXISTING DDB table (and append the data to it), then consider Glue.如果您希望将数据从源 DDB 表复制到现有 DDB 表(并将 append 数据复制到其中),请考虑使用 Glue。
If you just want to do it one time like you mention in the comments, I recommend doing a backup and restore.如果您只想像评论中提到的那样做一次,我建议您进行备份和恢复。 Restore always goes to a separate table, not the original one.
还原总是转到单独的表,而不是原始表。
What do you think about this:你怎么看待这件事:
import boto3
def migrate(source, target):
dynamo_client = boto3.client('dynamodb', region_name='us-east-1')
dynamo_target_client = boto3.client('dynamodb', region_name='us-west-2')
dynamo_paginator = dynamo_client.get_paginator('scan')
dynamo_response = dynamo_paginator.paginate(
TableName=source,
Select='ALL_ATTRIBUTES',
ReturnConsumedCapacity='NONE',
ConsistentRead=True
)
for page in dynamo_response:
for item in page['Items']:
dynamo_target_client.put_item(
TableName=target,
Item=item
)
if __name__ == '__main__':
migrate('awesome-v1', 'awesome-v2')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.