Add index:
db.test1.createIndex({name: 1},{unique: true}); # Name is the key word Unique: unique index
db.test1.getindexes () # Query index
Appears when Python inserts duplicate data pymongo.errors.DuplicateKeyError Wrong.
try:
db.test1.save(post)
except pymongo.errors.DuplicateKeyError:
print(111)
Read More:
- pymongo.errors.DuplicateKeyError: E11000 duplicate key error collection: anjuke.ershoufang index
- Error in Python connection to mongodb pymongo.errors.OperationFailure : Authentication failed.
- Errors encountered by elasticsearch in creating index and mapping
- [Oracle] when inserting data, “ora-00001: unique constraint” appears
- [Solved] Es delete all the data in the index without deleting the index structure, including curl deletion
- Index error: invalid index to scalar variable
- On set in pandas_ Index and reset_ Usage of index
- How to use the menu of elementui unique opened sidebar
- greendao insert data UNIQUE constraint failed: PURCHASE_ORDER_TABLE._id (code 1555)
- python sqlite Error IntegrityError: UNIQUE constraint failed: table_area1.user_name
- np.unique Usage of ()
- django.db.utils.IntegrityError: UNIQUE constraint failed: auth_user.username
- Numpy adds a new dimension: newaxis
- Clion automatically adds add_ executable
- JQ adds a click event to the option of select
- The SSM framework adds the mybatis paging plug-in to start the error report
- Clion develops STM32, adds files and compiles with an error “no such file or directory”“
- Methods of modifying index and columns names by dataframe in pandas
- MacOS adds code command to vs Code
- When react dynamically prunes components by operating arrays, the state of the remaining components is not preserved. Solution to the problem (method of dynamically setting unique key value)