This article mainly introduced the Pymongo to MongoDB to create the index simple implementation method, involves Python uses Pymongo module to operate the MongoDB the skill, needs the friend to be possible to refer to under
The following code creates a unique index for the user_name field of user
|1 2 3 4||Import Pymongo MONGO = Pymongo. Connection (' localhost ') collection = mongo[' database ' [' User '] collection.ensure_index (' user_name ', unique=true)|
I hope this article will help you with your Python programming.