二刷爬虫—MongoDB
2018-07-17 本文已影响0人
zhangyutong_dut
建立连接 client = pymongo.MongoClient(host="localhost",port=27017)
指定数据库 db=client.xxx
指定数据库中的集合 collection=db.xxx
插入数据 insert() 以字典作为参数
insert_one() insert_many()
查询数据 find_one() 返回一条结果
find() 返回生成器对象
计数 count()
排序 sort(排序字段,升序/降序) pymongo.ASCENDING/DESCENDING
偏移 skip()
指定要取的结果的个数 limit()
更新 update()
删除 remove()
delete_one() delete_many()