关于Python连接MongoDB
1、通过pip在Python中安装MongoDB的驱动程序。
在cmd命令中输入:python -m pip install pymongo
2、测试代码
#coding=utf-8
# 测试MongoDB
from pymongo import MongoClient
conn = MongoClient(‘127.0.0.1’, 27017)
# 连接cts数据库,没有则自动创建
db = conn.cts
# 使用user集合,没有则自动创建
1、通过pip在Python中安装MongoDB的驱动程序。
在cmd命令中输入:python -m pip install pymongo
2、测试代码
#coding=utf-8
# 测试MongoDB
from pymongo import MongoClient
conn = MongoClient(‘127.0.0.1’, 27017)
# 连接cts数据库,没有则自动创建
db = conn.cts
# 使用user集合,没有则自动创建
1、下载
mongodb-win32-x86_64-2008plus-ssl-4.0.3-signed.msi
mongodb-compass-1.15.4-win32-x64.exe
https://www.mongodb.com/download-center/community
https://www.mongodb.com/download-center/compass
2、安装MongoDB。MongoDB 4默认已经配置data、db、log、本地服务。