I have a dynamodb table in which columns are url and organization_name url is the primary key. How can I check if a url is already present in the table when I try to update the table with new data. I am using python boto3 for updating the table.
I used the below code for checking
trans = {}
trans['url'] = URL
trans['html_data'] = data
trans['organization_name'] = org_name
try:
table.put_item(Item=trans,ConditionExpression='attribute_not_exists(url)')
except:
mesg = 'Data Insertion Not Successfull'
mesg = 'Data Saved Successfully'
Is this the correct way for writing data to the table if url is not present.