Processing operation MongoDB ObjectId when Python inquiry

Bson ObjectId object from the introduction, the object query string into use id:

from bson import ObjectId
import pymongo
conn = pymongo.MongoClient('mongodb://root:[email protected]/admin'
str = "5sdfadsfasdfxzcasdfasdfas"
findinfo = conn.db_name.table_name.find({"_id" : ObjectId(str)})

 

Guess you like

Origin www.cnblogs.com/frisk/p/11568402.html