python mongodb

下载mango数据库

https://www.runoob.com/mongodb/mongodb-window-install.html

程序调用

安装依赖

pip install pymongo

简单使用

import pymongo

# Connect to MongoDB
myclient = pymongo.MongoClient("mongodb://localhost:27017/")

# Create database
mydb = myclient["mydatabase"]

# Create collection
mycol = mydb["customers"]

# Insert document
mydict = {"name": "John", "address": "Highway 37"}
x = mycol.insert_one(mydict)

更多信息文档:
https://juejin.cn/post/6844903597465927694
https://docs.mongoing.com/the-mongo-shell

posted @ 2023-05-24 10:26  一枚码农  阅读(12)  评论(0编辑  收藏  举报