I am using DynamoDB under Python environment and I would like to use the following DynamoDB as an example:
id | time | value |
---|---|---|
1 | 1 | 1 |
2 | 2 | 3 |
1 | 2 | 4 |
1 | 3 | 4 |
1 | 4 | 6 |
For the second criteria, I would like to know if I need to perform a get operation first or I could perform a write operation and, by table design, could raise an exception and then I ignore the exception (because the entry already exist in DynamoDB).
You'll want to have your code use a partition key that is the compound value of id and time separated by something like a hash. Like 1#1
.
You can insert data with a PutItem having a conditional expression to fail if the PK already exists.
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.