1
私はPythonでAWSラムダ関数をプログラミングしています。私はboto3を使用してDynamoDBデータベースに接続していますが、最後のロケーションエントリを取得しようとしています。AWS Lambda DynamoDBクエリエラー
DynamoDBテーブルには、プライマリパーティションキーが "シリアル"(文字列)、プライマリソートキーが "時間"(文字列)になっています。
私はこのコードを実行する、シリアルのための最後のエントリを取得するには、「0001」をしようと、私は次のエラーを取得する
def getPriorGeofence(device):
client = boto3.client('dynamodb')
response = client.query(
TableName='Locations',
IndexName='Serial',
Select='ALL_ATTRIBUTES',
Limit=1,
ScanIndexForward=True,
KeyConditions={
"Serial":{
'ComparisonOperator': "EQ",
'AttributeValueList': [device]
}
}
)
return response
エラー
{
"stackTrace": [
[
"/var/task/lambda_function.py",
154,
"lambda_handler",
"priorGeofence = getPriorGeofence(serial)"
],
[
"/var/task/lambda_function.py",
110,
"getPriorGeofence",
"'AttributeValueList': [device]"
],
[
"/var/runtime/botocore/client.py",
253,
"_api_call",
"return self._make_api_call(operation_name, kwargs)"
],
[
"/var/runtime/botocore/client.py",
517,
"_make_api_call",
"api_params, operation_model, context=request_context)"
],
[
"/var/runtime/botocore/client.py",
572,
"_convert_to_request_dict",
"api_params, operation_model)"
],
[
"/var/runtime/botocore/validate.py",
270,
"serialize_to_request",
"raise ParamValidationError(report=report.generate_report())"
]
],
"errorType": "ParamValidationError",
"errorMessage": "Parameter validation failed:\nInvalid type for parameter KeyConditions.Serial.AttributeValueList[0], value: 0001, type: <type 'unicode'>, valid types: <type 'dict'>"
}