Hi,
I’m using Python and I’m trying to do a compare in 2 collections to push any new changes or inserts to a 3rd collection.
I have a current collection and another collection that will be updated with new data. I want to see if there is any change of the new data when compared to the current collection and if so push it to a 3rd collection in order to push to an external system.
I searched and found some possible ideas but figured I’d just start with trying to pull data from the 2 collections based on one value. However, I’m getting stuck with the find_one query part. What I have so far:
>>>results=[]
>>> results.append(deptload.find_one())
>>>for item in results:
deptid=item['DeptId']
item2=deptprior.find_one({"Code":deptid})
print(item2['Name'])
The issue is with the deptid in ‘({“Code”:deptid})’. It won’t accept the value from deptid and is returning back TypeError: ‘NoneType’ object is not subscriptable.
However when I print the deptid and pass it manually with the actual numbers, “12000”, it works just fine and brings back the name.
First am I on the right track to compare 2 collections and push the changes to a 3rd. And secondly, what am I doing wrong with the deptid variable?
Thanks.