Demonstrate DeleteItem.
(client)
| 463 | # --------------------------------------------------------------------------- |
| 464 | |
| 465 | def delete_data(client) -> None: |
| 466 | """Demonstrate DeleteItem.""" |
| 467 | section("Step 8: Delete Data (DeleteItem)") |
| 468 | |
| 469 | # Delete the transaction-created user and order |
| 470 | client.delete_item( |
| 471 | TableName=USERS_TABLE, |
| 472 | Key={"userId": {"S": "user-004"}}, |
| 473 | ) |
| 474 | print(" ✓ Deleted user-004") |
| 475 | |
| 476 | client.delete_item( |
| 477 | TableName=ORDERS_TABLE, |
| 478 | Key={ |
| 479 | "customerId": {"S": "user-004"}, |
| 480 | "orderId": {"S": "ord-401"}, |
| 481 | }, |
| 482 | ) |
| 483 | print(" ✓ Deleted order ord-401") |
| 484 | |
| 485 | # Verify deletion |
| 486 | resp = client.get_item( |
| 487 | TableName=USERS_TABLE, |
| 488 | Key={"userId": {"S": "user-004"}}, |
| 489 | ) |
| 490 | assert "Item" not in resp, "user-004 should be deleted" |
| 491 | print(" ✓ Verified user-004 no longer exists") |
| 492 | # --------------------------------------------------------------------------- |
| 493 | # Step 9: Drop tables |
| 494 | # --------------------------------------------------------------------------- |
no test coverage detected