Amazon DynamoDB
开发人员指南 (API 版本 2012-08-10)
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门 程序向 TryDaxTable 中写入测试数据。

# Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. # # This file is licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. A copy of # the License is located at # # # # This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. # import os import boto3 table_name = 'TryDaxTable' some_data = 'X' * 1000 pk_max = 10 sk_max = 10 region = os.environ.get('AWS_DEFAULT_REGION', 'us-west-2') dynamodb = boto3.client('dynamodb', region_name=region) for ipk in range(1, pk_max+1): for isk in range(1, sk_max+1): params = { 'TableName': table_name, 'Item': { 'pk': {'N': str(ipk)}, 'sk': {'N': str(isk)}, 'someData': {'S': some_data} } } dynamodb.put_item(**params) print(f'PutItem ({ipk}, {isk}) succeeded')