Reputation: 2387
My goal is to get similar object that I get through:
dynamodb = boto3.resource(service_name='dynamodb')
self._table = dynamodb.Table(name)
but through the Client
object.
How can I reference a DynamoDB
table through the low-level Client object?
Here is my code,
import boto3
cli = boto3.client('dynamodb')
cli.get_item(TableName=TABLE_NAME)
but I get the following error:
botocore.exceptions.ParamValidationError: Parameter validation failed:
Missing required parameter in input: "Key"
from the official documentation I saw that the Key
is a dictionary of returned properties, but couldn't wrap my head around what it actually represents.
I'd really appreciate any help.
Thanks in advance.
Upvotes: 1
Views: 262
Reputation: 3537
You should use The primary key attribute values that define the items and the attributes associated with the items.
boto_client.get_item(TableName='string', Key={})
by client.get_item:
client = boto3.client('dynamodb')
client.get_item(TableName='YourTable', Key={'PrimaryKeyName': {'ValueType':'Value'}})
where:
notice, that if your value is Number you use N but value will be inside quotes anyway
Upvotes: 3