I want to insert data into dynamodb local. However, I have only one key attribute and multiple non-key attributes.
{
'id':'99876983ydbhdu3739',
'category':'Spa',
'latitude':'33.498',
'longitude':'32.332',
'name':'Studio'
}
I have multiple such values. This is one record, an example of what I want to insert. Following is what I am trying:
table = dynamodb.create_table(
TableName='Trial',
KeySchema=[
{
'AttributeName': 'facebook_id',
'KeyType': 'HASH' #Sort key
},
{
'AttributeName': 'latitude',
'KeyType': 'RANGE' #Sort key
},
],
AttributeDefinitions=[
{
'AttributeName':'id',
'AttributeType':'S'
},
{
'AttributeName': 'category',
'AttributeType': 'S'
},
{
'AttributeName': 'latitude',
'AttributeType': 'S'
},
{
'AttributeName': 'longitude',
'AttributeType': 'S'
},
{
'AttributeName': 'name',
'AttributeType':'S'
}
],
ProvisionedThroughput={
'ReadCapacityUnits': 10,
'WriteCapacityUnits': 10
}
)
I get the following error:
An error occurred (ValidationException) when calling the CreateTable operation: The number of attributes in key schema must match the number of attributesdefined in attribute definitions.