General Problem
I have followed this tutorial on creating and accessing an Amazon DynamoDB from an Android application, and then adapted it for use in an app I am writing. It works great despite the difficulties I faced getting it up and running. However, I would also like to be able to access the database using a python script running on my Raspberry Pi.
I have found this tutorial, but it seems to only describe how to interact with a local DynamoDB table.
Specific Problem
The following code connects and writes an item to a DynamoDB table. I can't find any sort of endpoint URL for my Amazon DynamoDB, only the ARN, and there is no passing of a password or username as I use in my App.
# Helper class to convert a DynamoDB item to JSON.
class DecimalEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
if o % 1 > 0:
return float(o)
else:
return int(o)
return super(DecimalEncoder, self).default(o)
dynamodb = boto3.resource('dynamodb', region_name='us-west-2', endpoint_url="http://localhost:8000")
table = dynamodb.Table('Movies')
title = "The Big New Movie"
year = 2015
response = table.put_item(
Item={
'year': year,
'title': title,
'info': {
'plot':"Nothing happens at all.",
'rating': decimal.Decimal(0)
}
}
)
I have searched for any sort of instructions for connecting to an Amazon DynamoDB instance, but everything I have found describes a local table. If anyone can give advice for the specific issue or recommend a tutorial to that effect, I would appreciate it immensely.