Reputation: 13
def main():
alias = "jen"
ddb = boto3.client("dynamodb")
get_ddb_item = ddb.get_item(TableName="testtable", Key={"employee": {"S": alias}})
item = get_ddb_item["Item"]
print(item)
if item == alias:
print(f"{alias} is an employee")
else:
print(f"{alias} is not an active employee")
The only content on the testtable
is PK: employee item: "jen"
I am expecting an out put of jen is an employee
This is my code above and it gives me the opposite jen is not an active employee
What is the right way of getting the expected output?
Upvotes: 0
Views: 194
Reputation: 19893
You're getting this because item != 'jen'
if item['employee']['S'] == alias:
print(f"{alias} is an employee")
else:
print(f"{alias} is not an active employee")
Upvotes: 1