MongoDB的下载、安装及使用


一、下载

下载地址:https://www.mongodb.com/try/download/community

选择要下载的版本,匹配对应的系统

二、安装

选择next

选择next

选择custom

选择安装路径

选择next

不安装MongoDB 可视化工具 MongoDB Compass

选择install

三、使用

在python中的使用

先安装pymongo库

pip install pymongo

python中调用pymongo

import pymongo

# 连接MongoDB
client = pymongo.MongoClient(host='localhost', port=27017)
# 指定数据库
db = client.test
# 指定集合
collection = db.students
# 插入数据
student = {
    'id': '1',
    'name': 'zhangsan',
    'age': 20
}
result = collection.insert_one(student)
print(result)
# 查询数据
result = collection.find_one({'name': 'zhangsan'})
print(result)

文章作者: 星凌映雪
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 星凌映雪 !
评论
 上一篇
Flask项目对接钉钉第三方扫码登录 Flask项目对接钉钉第三方扫码登录
一、注册钉钉开放平台通过https://oa.dingtalk.com/register_new.htm注册钉钉开放平台 注册成功后,可以自己创建个公司团队 二、创建扫码登录应用官方文档如下:https://ding-doc.dingta
2020-12-22
下一篇 
PostgreSQL的下载、安装及使用 PostgreSQL的下载、安装及使用
一、下载PostgreSQL官网下载地址:https://www.postgresql.org/ 选择下载按钮 选择对应的系统,我的是win10 选择下载按钮 选择对应的系统和要下载的PostgreSQL版本 二、安装选择next
  目录