5

In AWS Dynamo DB we would like to automatically generate a unique id for our primary key when we call our update/put spotid function:

dynamodb.put_item(
    TableName = tablesinfo, Item = {
      'spot_id':{'N' : spot_id},
      'latitude':{'N' : lat},
      'longitude':{'N' : lon},
      'description':{'S' : descrip}
      }

Note code is in Python but since we plan on using AWS Lambda for this we can also use Java or Node.JS, However we would prefer if DynamoDB could handle this function.

Y Anderson
  • 427
  • 3
  • 5
  • 15
  • Related questions: http://stackoverflow.com/questions/11721308/how-to-make-a-uuid-in-dynamodb & http://stackoverflow.com/questions/8982148/uuids-for-dynamodb – routeburn Feb 25 '16 at 07:28

1 Answers1

7

DynamoDb will not generate any primary keys for you (one of the many ways it differs from relational databases).

You could just generate a unique id in code when you put an item. Java/Node/Python all have ways of generating GUIDs/UUIDs.

Check out this question to find out how to do it in Python: How to create a GUID/UUID in Python.

Community
  • 1
  • 1
routeburn
  • 1,156
  • 1
  • 12
  • 27