Created
July 16, 2020 21:22
-
-
Save MohamedRajabMohammed/3652511657ef1dbd1fd60a908d18bb55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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