下载MongoDB
参考下面博客:
https://blog.csdn.net/sliver_goup/article/details/112550424
配置本地MongoDB
每次启动都需要在CMD中配置,找到安装目录下的bin文件夹路径
配置数据库路径,配置前要在某一个盘中新建文件夹:D:\data\db
mongod --dbpath D:\data\db
再打开另外一个CMD,输入mongo;
如图片所示即MongoDB正常启动
在pycharm中安装Mongo Plugin
在文件找到settings,然后按图片下载:
然后重启。
光标停留在图标上,然后选择Mongo Explorer
如下图操作即可完成:
将数据存入MongoDB
import pymongo
#1建立连接
client = pymongo.MongoClient('localhost',27017)
#2新建名为weather的数据库
book_weather=client['weather']
#3新建名为sheet_weather的表
sheet_weather = book_weather['sheet_weather_3']
#写入数据
sheet_weather.insert_one({'city':'北京'})