As the title. It seems that pymongo does not support, is there any other easy way to get.
As the title. It seems that pymongo does not support, is there any other easy way to get.
Once you are connected to your MongoDB via pymongo you can retrieve the version with:
db.command({'buildInfo':1})['version']
This would return e.g. '4.4.5'.
from pymongo import MongoClient
client = MongoClient(uri)
version = client.server_info()["version"]
version_array = client.server_info()["versionArray"]
print(version)
>>> '4.4.4'
print(version_array)
>>> [4, 4, 4, 0]