amazon-dynamodb

DynamoDb update using boto3

DynamoDb update using boto3 Question: I am writing a lambda function to update dynamodb item. But the problem is that when I give { "employee_id": "1", "last_name": "jane", "first_name": "anderson" } It works fine but if you remove the last_name or the first_name the program crashes.I want to make it dynamic like if I provice …

Total answers: 2

How to get dynamodb to only return certain columns

How to get dynamodb to only return certain columns Question: Hello, I have a simple dynamodb table here filled with placeholder values. How would i go about retrieving only sort_number, current_balance and side with a query/scan? I’m using python and boto3, however, just stating what to configure for each of the expressions and parameters is …

Total answers: 3

DynamoDB Python API: Way to check result of conditional expression?

DynamoDB Python API: Way to check result of conditional expression? Question: Using DynamoDB, I know I can specify a conditional expression to control updates, for example, using attribute_not_exists() to prevent overwriting an existing item. However, is there any way to check the result of this? I.e. if there was indeed an existing item and the …

Total answers: 2

Using a ProjectionExpression with reserved words with Boto3 in DynamoDB

Using a ProjectionExpression with reserved words with Boto3 in DynamoDB Question: I’m selecting data from my DynamoDB database using boto3 dynamodb = boto3.resource(‘dynamodb’) table = dynamodb.Table(table_name) response = table.scan(ProjectionExpression=’Id,Name’)[‘Items’] Works fine. Now I also want to retrieve an attribute that is (unfortunately) named with a reserved word – let’s say CONNECTION. response = table.scan(ProjectionExpression=’Id,Name,Connection’)[‘Items’] I …

Total answers: 1

Update nested map dynamodb

Update nested map dynamodb Question: I have a dynamodb table with an attribute containing a nested map and I would like to update a specific inventory item that is filtered via a filter expression that results in a single item from this map. How to write an update expression to update the location to "in …

Total answers: 5

Boto 3 DynamoDB batchWriteItem Invalid attribute value type when specifying types

Boto 3 DynamoDB batchWriteItem Invalid attribute value type when specifying types Question: I have a strange problem with Python Boto3 when trying to do a batch_write_item to a DynamoDB table. I am following the documentation and trying to write a singe item. The table is setup correctly and I can run batch-write-item via the AWS …

Total answers: 2

Use .contains() to retrieve values from DynamoDB

Use .contains() to retrieve values from DynamoDB Question: I’m new with NoSQL Databases and am stuck with a problem. I just want to get keys from a table in DynamoDB that contains a specific value. I know that for key equals I can use: response = table.query( KeyConditionExpression=Key(‘year’).eq(1992) ) But I can’t use: response = …

Total answers: 3

How to convert a boto3 Dynamo DB item to a regular dictionary in Python?

How to convert a boto3 Dynamo DB item to a regular dictionary in Python? Question: In Python, when an item is retrieved from Dynamo DB using boto3, a schema like the following is obtained. { “ACTIVE”: { “BOOL”: true }, “CRC”: { “N”: “-1600155180” }, “ID”: { “S”: “bewfv43843b” }, “params”: { “M”: { “customer”: …

Total answers: 4

"The provided key element does not match the schema" error when getting an item from DynamoDB

"The provided key element does not match the schema" error when getting an item from DynamoDB Question: This is the table partition key setting The table content When I tried to get an item from the table, it prints this error botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the GetItem operation: The provided key element …

Total answers: 4

How to check if DynamoDB table exists?

How to check if DynamoDB table exists? Question: I’m a new user in boto3 and i’m using DynamoDB. I went through over the DynamoDB api and I couldn’t find any method which tell me if a table is already exists. What is the best approach dealing this issue? Should I try to create a new …

Total answers: 8