随笔分类 -  mongo

摘要:from bson.objectid import ObjectId 1、字符串转ObjectId oid = ObjectId(id_str); 2、ObjectId转字符串 id_str = ObjectId(id).toString() 例子 find({'_id': ObjectId(id_ 阅读全文
posted @ 2020-04-23 17:04 阿磊小哥哥呀 阅读(1510) 评论(0) 推荐(0)
摘要:导入pymongo并选择要操作的集合 数据库和集合乜有会自动创建 from pymongo import MongoClient client = MongoClient(host,port) collection = client[db名][集合名] 添加一条数据 ret = collection 阅读全文
posted @ 2020-04-17 09:17 阿磊小哥哥呀 阅读(873) 评论(0) 推荐(0)