I have this code below to scan all items in my users table and then print the name of each item.
And Im printing the field name of each item, and its working correctly when all items have the field name filled.
But when some item dont have the field name filled I got an error in print r["name"].
Error: key error "name"
Do you know why I get this error? Dynamodb dont let us have empty fields? Or this isnt the correct way to get all items from a table?
Code:
dynamo = boto.dynamodb.connect_to_region("us-east-1")
table = dynamo.get_table("users")
results = table.scan()
print results
for r in results:
print r["name"]
Aucun commentaire:
Enregistrer un commentaire