■property.py
Python コード
■solution1.txt
シフト解
■solution1_task.txt
タスク解
■Status
GUI出力
bool update_item(string table_name,string item_name,string attribute_name, string &description)
{
const Aws::String tableName=table_name;//(argv[1]);
const Aws::String keyValue=item_name;//(argv[2]);
const Aws::String attributeNameAndValue=attribute_name;//(argv[3]);
// snippet-start:[dynamodb.cpp.update_item.code]
Aws::Client::ClientConfiguration clientConfig;
Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfig);
// *** Define UpdateItem request arguments
// Define TableName argument
Aws::DynamoDB::Model::UpdateItemRequest request;
request.SetTableName(tableName);
// Define KeyName argument
Aws::DynamoDB::Model::AttributeValue attribValue;
attribValue.SetS(keyValue);
request.AddKey("Name", attribValue);
// Construct the SET update expression argument
Aws::String update_expression("SET #a = :valueA");
request.SetUpdateExpression(update_expression);
// Parse the attribute name and value. Syntax: "name=value"
//auto parsed = Aws::Utils::StringUtils::Split(attributeNameAndValue, '=');
// parsed[0] == attribute name, parsed[1] == attribute value
//if (parsed.size() != 2)
//{
// std::cout << "Invalid argument syntax: " << attributeNameAndValue << USAGE;
// return 1;
//}
// Construct attribute name argument
// Note: Setting the ExpressionAttributeNames argument is required only
// when the name is a reserved word, such as "default". Otherwise, the
// name can be included in the update_expression, as in
// "SET MyAttributeName = :valueA"
Aws::Map expressionAttributeNames;
expressionAttributeNames["#a"] = attribute_name;//parsed[0];
request.SetExpressionAttributeNames(expressionAttributeNames);
// Construct attribute value argument
Aws::DynamoDB::Model::AttributeValue attributeUpdatedValue;
attributeUpdatedValue.SetS(description);//parsed[1]);
Aws::Map expressionAttributeValues;
expressionAttributeValues[":valueA"] = attributeUpdatedValue;
request.SetExpressionAttributeValues(expressionAttributeValues);
// Update the item
const Aws::DynamoDB::Model::UpdateItemOutcome& result = dynamoClient.UpdateItem(request);
if (!result.IsSuccess())
{
std::cout << result.GetError().GetMessage() << std::endl;
return false;
}
std::cout << "Item was updated" << std::endl;
return true;
// snippet-end:[dynamodb.cpp.update_item.code]
}
0 件のコメント:
コメントを投稿