Skip to content

Instantly share code, notes, and snippets.

@MohamedRajabMohammed
Created July 16, 2020 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MohamedRajabMohammed/3652511657ef1dbd1fd60a908d18bb55 to your computer and use it in GitHub Desktop.
Save MohamedRajabMohammed/3652511657ef1dbd1fd60a908d18bb55 to your computer and use it in GitHub Desktop.
def add_product_detail(details):
new = db["products"]
ASIN = details["url"][len(details["url"])-10:len(details["url"])]
details["date"] = datetime.datetime.utcnow()
try:
new.update_one(
{
"asin":ASIN
},
{
"$set": {
"asin":ASIN
},
"$push":{
"details":details
}
},
upsert=True
)
return True
except Exception as identifier:
print(identifier)
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment