pymongo - MongoClient retryWrites=false is not working

Viewed 1114

I'm currently working on a simple python CRUD script to check MongoDB out. Turns out I'm liking it a lot, but I have found myself being unable to work with MongoDB transactions. Everytime I try to start a transaction an exception is thrown saying:

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

And, eventhough I've already added that option to my connection string:

self._client = MongoClient('mongodb://localhost/?retryWrites=false')
self._db = self._client.workouts
self._collection = self._db.workouts

That error is still popping up when running the following lines of code:

with self._client.start_session() as s:
    with s.start_transaction():
        self._collection.delete_one({'_id': id}, session=s)
        next = self._collection.find_one({'_id': next_id}, session=s)
        return next

What can I do?

I'm running python 3.7.3, pymongo 3.9.0 and MongoDB 4.0.12.

0 Answers
Related