Skip to content Skip to sidebar Skip to footer

Can't Create Index Due To Typeerror: Not Enough Arguments For Format String

I am trying to create indices with pymongo, but failing with error File 'D:/Users/Dims/Design/EnergentGroup/Python GIS Developer/worker/Approach03\sentinel\mongo.py', line 46, in g

Solution 1:

This syntax is not what PyMongo requires:

results_collection.create_index(["uwi", "date_part"], name=index_name, unique=True)

You want an index on the two fields, "uwi" and "date_part"? Choose carefully what order to index the fields in (see Optimizing MongoDB Compound Indexes) and whether to index them in ascending or descending order.

If you want to index "uwi" and "date_part" in that order, both ascending, then do this:

results_collection.create_index([("uwi", 1), ("date_part", 1)], name=index_name, unique=True)

For more info on creating indexes with PyMongo, see the documentation.

Post a Comment for "Can't Create Index Due To Typeerror: Not Enough Arguments For Format String"