0
0
DynamoDBquery~10 mins

Key-value and document store model in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to put an item into a DynamoDB table.

DynamoDB
response = table.put_item(Item={'UserId': '123', 'Name': [1])
Drag options to blanks, or click blank then click option'
AUserId
B'Alice'
C123
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using attribute names instead of values
Forgetting quotes around string values
2fill in blank
medium

Complete the code to get an item by its primary key from the DynamoDB table.

DynamoDB
response = table.get_item(Key={'UserId': [1])
Drag options to blanks, or click blank then click option'
A'Name'
BName
C123
D'123'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around string key values
Using attribute names instead of values
3fill in blank
hard

Fix the error in the code to update an attribute in a DynamoDB item.

DynamoDB
response = table.update_item(Key={'UserId': '123'}, UpdateExpression='SET [1] = :val', ExpressionAttributeValues={':val': 'Bob'})
Drag options to blanks, or click blank then click option'
AName
B'UserId'
CUserId
D'Name'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around attribute names in UpdateExpression
Using wrong attribute names
4fill in blank
hard

Fill both blanks to query items where 'Age' is greater than 25.

DynamoDB
response = table.query(KeyConditionExpression=[1].eq('123'), FilterExpression=[2].gt(25))
Drag options to blanks, or click blank then click option'
AKey('UserId')
BKey('Age')
CAttr('Age')
DAttr('UserId')
Attempts:
3 left
💡 Hint
Common Mistakes
Using Attr() for partition key
Using Key() for non-key attributes
5fill in blank
hard

Fill all three blanks to create a dictionary of item names and their prices for items priced above 100.

DynamoDB
result = {item['[1]']: item['[2]'] for item in items if item['[3]'] > 100}
Drag options to blanks, or click blank then click option'
AName
BPrice
DQuantity
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute names
Mixing up keys and values in the dictionary comprehension