1. python操作MySQL
2. python操作MongoDB
2.1 MongoDB基础
2.2 pymongo模块
2.2.1 安装pymongo
pip install pymongo -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
2.2.2 连接MongoDB
- import pymongo
- #获取连接的对象,两种连接方式都可以
- client = pymongo.MongoClient('127.0.0.1',port=27017)
- # client = pymongo.MongoClient('mongodb://localhost:27017/')
- #获取数据库
- db = client.newdb
- #获取集合(表)
- collection = db.stu
- #插入一条数据到集合中
- collection.insert_one({
- "name":"xhh",
- "gender":"true",
- "age&#