Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

retryWrites in mongodb python

I use pymongo to implement mongo database. I am trying to use the sessions and transactions for the management of operations, but I encountered this error:

pymongo.errors.OperationFailure: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.

I tried this solution but without result:

myclient = pymongo.MongoClient("mongodb://localhost:27017/", retryWrites=False)
db = myclient["mydb"]
session = myclient.start_session()

Any help, thanks

like image 745
Zouhair Elhadi Avatar asked Jun 03 '26 13:06

Zouhair Elhadi


1 Answers

You need to run with the full connection string

myclient = pymongo.MongoClient("mongodb://localhost:27017/&retryWrites=false")

or specify all parameters

myclient = pymongo.MongoClient(host="localhost", port=27017, retryWrites=False)
like image 176
trgiangdo Avatar answered Jun 06 '26 04:06

trgiangdo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!