System environment: Windows Ten, python3.x
1. Installing MongoDB
MongoDB Download Website: https://www.mongodb.com/download-center?jmp=nav#community
Installation Tutorial Online A lot, you can self-Baidu (http://www.cnblogs.com/lzrabbit/p/3682510.html), the focus is configuration!
Method One:
Configuration Data Directory
Mongod--dbpath D:\MongoDB\data--install
Configuration Log
Mongod--logpath= ' D:\MongoDB\logs\mongodb.log '--logappend
Method Two:
Configuring the MongoDB configuration file
Eg: setting up the profile directory D:\MongoDB\etc
Dbpath=d:\mongodb\data #数据库路径logpath =d:\mongodb\logs\mongodb.log #日志输出文件路径logappend =true #错误日志采用追加模式, When this option is configured, the MongoDB log is appended to the existing log file instead of the new file Journal=true #启用日志文件, Quiet=true #这个选项可以过滤掉一些无用的日志信息 is enabled by default, If you need to debug use set to falseport=27017 #端口号 default to 27017
Installing as a system service
Mongod--config D:\MongoDB\etc\mongodb.conf--install
Start
net start MongoDB
Stop it
net stop MongoDB
2. Using the MongoDB visualizer
I'm using it. Robomongo, website link: https://robomongo.org/download
3. Installing Pymongo
Pip Install Pymongo
4. Testing
test.py
Import Pymongo as pm# gets the connection client = PM. Mongoclient (' localhost ', 27017) # port number is numeric # connection Database db = client.test# Get collection STB = db.student# Get data information datas = Stb.find () for DA Ta in datas: # Print (Data.keys ()) # Gets the field property in the collection print (data)
Operation Result:
Python using MongoDB