AWS dynamodb boto3 ResourceNotFoundException:调用 PutItem 操作时出错:
AWS dynamodb boto3 ResourceNotFoundException: An error occurred when calling the PutItem operation:
我是 AWS 和 DynamoDB 的新手,我正在尝试将数据发送到 table。
我是运行这个代码:
import boto3
db = boto3.resource('dynamodb')
table = db.Table('Whales')
table.put_item(
Item={
"id": "1573138502",
"transaction_type": "transfer",
})
我得到这个错误:
Traceback (most recent call last):
File "/Users/---/Desktop/---/---/test.py", line 6, in <module>
table.put_item(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(*args, **params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/botocore/client.py", line 676, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the PutItem operation: Requested resource not found
我安装了 boto3,我使用 aws cli 进行了身份验证,我也尝试了 运行 来自 AWS Cloud9 EC2 的代码,但它没有工作,同样的错误。
我无法从 Python 向数据库发送任何内容,我不明白问题的来源或原因。
您的 DynamoDB Table 很可能与您在 ~/.aws/config
中指定的区域不同。
尝试 cat ~/.aws/config
并检查您正在连接的区域。即us-east-1
.
使用 AWS 控制台或其他 CLI 工具验证您的 DynamoDB 是否位于同一区域。
据我所知,您的代码在语法上应该没有错误。
我是 AWS 和 DynamoDB 的新手,我正在尝试将数据发送到 table。
我是运行这个代码:
import boto3
db = boto3.resource('dynamodb')
table = db.Table('Whales')
table.put_item(
Item={
"id": "1573138502",
"transaction_type": "transfer",
})
我得到这个错误:
Traceback (most recent call last):
File "/Users/---/Desktop/---/---/test.py", line 6, in <module>
table.put_item(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(*args, **params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/botocore/client.py", line 676, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the PutItem operation: Requested resource not found
我安装了 boto3,我使用 aws cli 进行了身份验证,我也尝试了 运行 来自 AWS Cloud9 EC2 的代码,但它没有工作,同样的错误。
我无法从 Python 向数据库发送任何内容,我不明白问题的来源或原因。
您的 DynamoDB Table 很可能与您在 ~/.aws/config
中指定的区域不同。
尝试 cat ~/.aws/config
并检查您正在连接的区域。即us-east-1
.
使用 AWS 控制台或其他 CLI 工具验证您的 DynamoDB 是否位于同一区域。
据我所知,您的代码在语法上应该没有错误。