Hi want to add continuously to an sub-item which is initially declared empty and later will be updated.
Here is the code -
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000')
# Creating the Table
table = dynamodb.create_table(
TableName='TableN',
KeySchema=[
{
'AttributeName': 'name',
'KeyType': 'HASH'
}
],
AttributeDefinitions=[
{
'AttributeName': 'name',
'AttributeType': 'S'
}
],
ProvisionedThroughput={
'ReadCapacityUnits': 1000,
'WriteCapacityUnits': 1000
}
)
# Updating with the Initial Values
table = dynamodb.Table('TableN')
IntValues = {
"datapoints": [],
"attributes": {"host": "server1", "customer": "Ast1"},
"name": "B001_P001"
}
table.put_item(Item=IntValues)
Now i want to update the "datapoints" with the set of values -
datapoint1 = {"x1":1,"x2":"OK","x3":"23.123"}
datapoint2 = {"x1":3,"x2":"ON","x3":"56.123"}
datapoint3 = {"x1":5,"x2":"OFF","x3":"78.123"}
So that final value should look like -
{
"name" : "B001_P001",
"datapoints" : [
{
"x1" : 1,
"x2" : "OK",
"x3":"23.123"
},
{
"x1" : 1,
"x2" : "OK",
"x3":"23.123"
},
{
"x1" : 1,
"x2" : "OK",
"x3":"23.123"
}]
"attributes": {"host": "server1", "customer": "Ast1"}
}
How can i update the existing sub-item without removing or creating again the entire item ?