I’m using Mongo db from Python.
Creating collections using this code:
self.client = MongoClient(MONGODB_CONNECT)
self.db = self.client[MONGODB_NAME]
self.db.create_collection(collection_name, options)
Where option is a dictionary like:
option = {
"timeseries": {
"timeField": "event_time",
"metaField": "metadata",
"granularity": "minutes"
},
"validator": event_validator, // another dictionary
}
This was fine yesterday.
For a deployment evolution reason I’ve updated Python from version 3.12.4 to 3.12.5.
I now have the following error on the ‘create_collection’ line:
codec_options must be an instance of bson.codec_options.CodecOptions
Indeed the documentation shows an optional codec_options parameter that I’ve never used.
I’m using PyMongo 4.8.0 and don’t think I’ve ever change this version.
I’m quite new to python so maybe I’m missing something obvious here…
I’m wondering why a Python update can cause such an error and how we should create a collection with an option dictionary on python 3.12.5.
EDIT (new try) :
I’ve seen example where validators are given with named parameter like so
self.db.create_collection(collection_name, validators=validators)
No success:
parameter validators is disallowed in create command, full error: {‘ok’: 0, ‘errmsg’: ‘parameter validators is disallowed in create command’, ‘code’: 8000, ‘codeName’: ‘AtlasError’}
3