WriteConcern implementation problems

I try to applied writeConcern:

db.users.insert_one({
“name”: name,
“email”: email,
“password”: hashedpw
},{writeConcern:{w:“majority”}})

I followed this example…
db.products.insert(
{ item: “envelopes”, qty : 100, type: “Clasp” },
{ writeConcern: { w: “majority” , wtimeout: 5000 } }
)

But I get this Error:

writeConcernerror

How can I save this mistake?
Thanks everyone

Where did you get the example?

Are you sure it is a python example? Looks like JavaScript.

From the documentation https://api.mongodb.com/python/current/api/pymongo/collection.html, I do not see anything that looks like what you are doing.

From MongoDB Manual, official page. I couldn’t find how to do in python. For this reason I wrote for help.
Thanks

In the link I provided, which I do not think you read because I usually see a little counter every time someone clicks on a link, search for the string with_options.

the link appears to be broken:

AccessDenied Access Denied W41YTDED5Z39NS3N iJJZp/Vp3SpLTtubsL/44JtIqV9FsBgA9JD4Px+AIn1UTB5HUFi2CjquLRha21Q7aO6KibaLLoI=

The link was posted more than 2 years ago.

The documentation must have move.

Try with collection – Collection level operations — PyMongo 2.2 documentation

Hi @steevej,

PyMongo 2.2 is even older (2012!). The current PyMongo release series is 4.0 :slight_smile:

@Russ_Cannizzo For current PyMongo documentation, please refer to:

The modern equivalent of the API link mentioned 2 years ago is: collection – Collection level operations — PyMongo 4.0.2 documentation.

Regards,
Stennie

3 Likes