Reputation:
My dynamodb table has user
as partition_key
and sort_key
as Time
I am searching for the type
which is in 'Product Team' from the dynamodb in prescribed format
Below i have added 3 items from the dynamo db table
{ "user": "[email protected]", "type": "Product Team", "message": "Developer", "employeeId": "101", "message_requested":"Requested for the 192.168.1.1 access" "Time": "2021-01-08 12:09:54.986542" },
{ "user": "[email protected]", "type": "Product Team", "message": "Developer", "employeeId": "101", "message_requested":"Requested for the 192.168.1.2 access" "Time": "2021-01-09 12:10:54.986542" },
{ "user": "[email protected]", "type": "Ops Team", "message": "Tester", "employeeId": "102", "message_requested":"Requested for the 192.168.1.1 access" "Time": "2021-01-08 11:09:54.986542" }
Expected out is
{"user":"[email protected]",
"params":[{"message_requested":"Requested for the 192.168.1.1 access"
"Time": "2021-01-08 12:09:54.986542"},
{"message_requested":"Requested for the 192.168.1.2 access"
"Time": "2021-01-09 12:10:54.986542"}]
}
Below is the code to extract the items from the dynamodb table
def details(type):
dynamodb = boto3.resource('dynamodb')
client = boto3.client('dynamodb')
table = dynamodb.Table("my_db_table_name")
#res = client.get_item(
# TableName=table,
# Key={
# 'type': {'S': 'Product Team'
# }})
res = table.scan(FilterExpression=Attr("type").eq("Product Team"))
return res
Upvotes: 0
Views: 898
Reputation: 151
There are two options:
Upvotes: 4