Reputation: 105
As the title. It seems that pymongo does not support, is there any other easy way to get.
Upvotes: 4
Views: 3480
Reputation: 105
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]
Upvotes: 6
Reputation: 1215
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'
.
Upvotes: 4