0

I uitilize boto3 to create a dynamo client and do an put_item operation. The item that is pushed to dynamodb is of following format. It has a string set datatype , which works.

my_list = ["abc", "efg" ...]
{
   "pk" : {"S": "2308ryfoif"}, 
   "some_list" : {"SS" : my_list}
    
}

now instead of each put_item , i want to use batch writer

dynamodb_table = boto3.resource('dynamodb').Table('example')
   with dynamodb_table.batch_writer() as batch:
        for i in list:
        batch.put_item(Item=i)

but the format or schema for batch operation , i understand is we don't have to specify datatype , such as

{
   "pk" : "2308ryfoif", 
   "some_list" : my_list
    
}

but this translates to a list in dynamodb, how can i post this as a string set ?

1 Answer 1

1

It saves as a list because you pass it a list. If you want a set, then you can convert your list to a set type:

{
   "pk" : "2308ryfoif", 
   "some_list" : set(my_list)
}

More info on python data structures here: https://docs.python.org/3/tutorial/datastructures.html#sets

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.