retryWrites in mongodb python

1.5k Views Asked by At

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

1

There are 1 best solutions below

0
On

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
)