简体   繁体   English

如何将数据从一个表传输到另一个表(AWS 上的 DynamoDB)

[英]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。

  • DDB can be a source for Glue ETL: "connectionType": "dynamodb" DDB 可以是 Glue ETL 的来源:“connectionType”:“dynamodb”
  • DDB can be a destination for Glue ETL, but is a little more complicated. DDB 可以成为 Glue ETL 的目标,但稍微复杂一些。 You will need to use the JDBC driver for DynamoDB and then set Glue to output to JDBC.您需要为 DynamoDB 使用 JDBC 驱动程序,然后将 Glue 设置为 output 到 JDBC。 There are detailed instructions here这里有详细说明

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:你怎么看待这件事:

  • Different Regions不同地区
  • Python Python
  • Pagination分页
  • Error handling and logs错误处理和日志
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.

相关问题 将本地DynamoDB实例中的表和表数据传输到AWS托管实例? - Transfer tables and table data in local DynamoDB instance to AWS hosted instance? 如何使用AWS Data Pipeline将文件从一个S3存储桶/目录传输到另一个 - How to transfer a file/files from one S3 bucket/directory to another using AWS Data Pipeline 单击HTML按钮时如何将数据从一个DynamoDB表移动到同一区域中的另一DynamoDB表 - How to move the data from one DynamoDB table to other DynamoDB table in the same region on click of HTML button 将数据从SQS传输到Dynamodb - Transfer data from SQS to Dynamodb 将域从一个 AWS 账户转移到另一个 AWS 账户 - Transfer domain from one AWS account to another AWS account 将选择性数据从一个 dynamodb 表导出到同一区域中的另一个表的选项 - Options to export selective data from one dynamodb table to another table in same region 从 AWS CDK 中的另一个堆栈更新 DynamoDB 表 - Update DynamoDB table from another stack in AWS CDK 将数据从一个AWS RDS实例传输到另一个实例的最有效方法是什么 - What's the most efficient way to transfer data from one AWS RDS instance to another 从一个账户中的 jenkins 启动 aws ssm 到另一个实例中的 ec2 以进行数据传输 - initiate aws ssm from jenkins in one account to ec2 in another instance for data transfer 如何在一个账户中使用 AWS AppSync 访问另一个账户中的 DynamoDB? - How to use AWS AppSync in one account access DynamoDB in another account?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM