mongo随写笔记

2017-08-26  本文已影响0人  随风而去_c0e8

连接数据库

from pymongo import MongoClient
client = MongoClient()  # connect database
db = client.chemicalbook1  # get database
collection = db['name']#creat names集合

插入文档

information = {"name": "quyang", "age": "25"}
information_id = collection .insert(information)#collcetion.save

查询文档

collection .find_one()#return one object
collection.find()#return every object

修改文档

collection.updata()#collection.save()

删除文档

collection.remove(dirt(data))#for ({'a':'qiye'})
Paste_Image.png

仅供新学的朋友借鉴,不好请多指教!!!

上一篇 下一篇

猜你喜欢

热点阅读