snippets_py
Integration
New integration from credential
aws_dynamodb_client = yepcode.integration.aws_dynamodb("credential-slug")
New integration from plain authentication data
import boto3
session = boto3.Session(
aws_access_key_id="accessKeyId",
aws_secret_access_key="secretAccessKey",
region_name="region"
)
aws_dynamodb_client = session.client("dynamodb")
List Tables
List tables
response = aws_dynamodb_client.list_tables()
for table in response.get("TableNames", []):
print(table)
Get All Table Items
Get all table items
response = aws_dynamodb_client.scan(TableName='table-name')
for item in response.get("Items", []):
print(item)
Put Item
Put item
item = {
"key-property-name": {"S": "key-property-value"},
"other-prop": {"S": "other-value"},
}
aws_dynamodb_client.put_item(
TableName='table-name',
Item=item
)
Get Item
Get item
response = aws_dynamodb_client.get_item(
TableName='table-name',
Key={'key-property-name': {'S': 'key-property-value'}}
)
print(response.get("Item"))