I am trying to create a connection to a database - collection using a ClientSession
in pymongo 3.7.1. From the example provided by the doc here : https://docs.mongodb.com/manual/core/transactions/, it seems possible to get a connection to a database and cursor.
I tried something really similar :
import pymongo
client = pymongo.MongoClient('mongodb://localhost:27017')
session = client.start_session()
session.get_database('test')
But the last line raise the following exception :
AttributeError: 'ClientSession' object has no attribute 'get_database'
I also tried two other more direct access to the database :
session['test_database']
session.test_database
which raised :
TypeError: 'ClientSession' object has no attribute 'getitem'
AttributeError: 'ClientSession' object has no attribute 'db_test'
How does the ClientSession
behaves ? Apparently is does not inherit from the Client
object, otherwise the previous line would work...
Does someone have an idea ?