As the title. It seems that pymongo does not support, is there any other easy way to get.
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]
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'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With