Problem while using local dynamoDB container (Boto3 put_item error)

0 votes

I am testing out boto with a local dynamodb docker container, I get this error while putting a new item into the table. The table exists.

from __future__ import print_function # Python 2/3 compatibility
import boto3
import os

os.environ["AWS_ACCESS_KEY_ID"] = "localaccesskey"
os.environ["AWS_SECRET_ACCESS_KEY"] = "password"

conn = boto3.resource('dynamodb', aws_access_key_id="localaccesskey",  aws_secret_access_key="password", region_name='eu-west-1', endpoint_url="http://localhost:8000")
print(list(conn.tables.all()))


table = conn.Table('Movies')
table.put_item(
   Item={
        'username': 'janedoe',
        'first_name': 'Jane',
        'last_name': 'Doe',
        'age': 25,
        'account_type': 'standard_user',
    }
)

error:

/usr/bin/python2.7 /home/kshk/PycharmProjects/Skulldogo/eli.py
[dynamodb.Table(name=u'Movies'), dynamodb.Table(name=u'devApiConfig'), dynamodb.Table(name=u'devApiKeys'), dynamodb.Table(name=u'devObjectCache'), dynamodb.Table(name=u'devSessionCache'), dynamodb.Table(name=u'test'), dynamodb.Table(name=u'test1'), dynamodb.Table(name=u'test10')]
Traceback (most recent call last):
  File "/home/kshk/PycharmProjects/Skulldogo/eli.py", line 52, in <module>
    'account_type': 'standard_user',
  File "/usr/lib/python2.7/site-packages/boto3/resources/factory.py", line 518, in do_action
    response = action(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 258, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 548, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutItem operation: One of the required keys was not given a value

any ideas???

Dec 3, 2018 in Python by aryya
• 7,350 points
800 views

1 answer to this question.

0 votes
DynamoDB does not autogenerate the ID when creating new records. Make sure to supply the hash key.

Oh and the range key too when defined.
answered Dec 3, 2018 by charlie_brown
• 7,760 points

Related Questions In Python

0 votes
1 answer

Python error "ValueError: size needs to be (int width, int height)" while using pygame.Surface

pygame.Surface takes in integer values for building ...READ MORE

answered Jun 19, 2019 in Python by Varsha
555 views
0 votes
1 answer

error: while concatenation in a dataframe using pandas!

Hi@akhtar, When we use concat function we have ...READ MORE

answered May 5 in Python by MD
• 23,050 points
37 views
+2 votes
2 answers

Error while printing hello world in python.

You must be trying this command in ...READ MORE

answered Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
330 views
0 votes
2 answers

Python UnboundLocalError error while executing script

Inside your function when you say word=word+1, ...READ MORE

answered May 22 in Python by Ibrahim Nezar
• 140 points
279 views
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 57,530 points
750 views
0 votes
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 57,530 points
1,535 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,670 points
934 views
0 votes
2 answers
0 votes
1 answer

When I create and remove files rapidly on windows using python I get WindowsError (Error 5)

Here's the short answer: disable any antivirus or ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,760 points
494 views
+2 votes
2 answers

How to make a laplacian pyramid using OpenCV python?

down voteacceptTheeThe problem is that you're iterating ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,760 points
2,328 views