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,460 points
3,825 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,720 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
5,791 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, 2020 in Python by MD
• 95,460 points
3,779 views
+1 vote
3 answers

While using pyttsx 3 , I am having the following ERROR, i have installed pypiwin32

Try this: pip uninstall pyttsx3 Then: pip install pyttsx3==2.71 READ MORE

answered Aug 12, 2020 in Python by Eghosa
8,022 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
6,481 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
• 58,020 points
6,008 views
–1 vote
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
• 58,020 points
5,233 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,820 points
2,883 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,720 points
1,929 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,720 points
4,948 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP