'update() takes 2 positional arguments but 3 were given

I'm working on implementing simple CRUD functionality using MongoDB and PyMongo. My create and read functions work well. However, I'm getting positional argument error when trying to run my update function:

TypeError: update() takes 2 positional arguments but 3 were given

The code for the update function is:

 def update(self, data, updateData):
        resultCount = 0
        if data is not None and updateData is not None:
            resultsCount = self.database.animals.update_one(data, updateData)
            if resultCount != 0:
                print("Updated successfully"_
                return self.database.animals.find(data, {"_id": False}) #returns the updated data
            else:
                raise Exception("Update error, check your data again")
        else:
            raise Exception("Nothing to find, because a least one of the data parameters is empty")

This is how the code is implemented using a Jupyter notebook:

    data = {'name': 'Brett', 'age': '14'}
    aShelter.create(data)
    print('Data created')
    output = aShelter.read(data)
    for d in output:
        print(d)
    updateData = {"$set": {"age": '12'}}
    update = aShelter.update(data, updateData)
    for d in update:
        print(d)

The create and read functions, which are set up exactly like the update function, work without throwing the positional error. Where am I going wrong? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source