Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我编写了一个pymongo脚本来添加示例用户,但它不起作用 导入pymongo client=pymongo.MongoClient(“mongodb+srv://Debaditya:@pycluster.d6kvk.gcp.mongodb.net/?retryWrites=true&w=mailty”) db=client.test 命令(“createUser”,“sample”,roles=[“read”])_Python - Fatal编程技术网

Python 我编写了一个pymongo脚本来添加示例用户,但它不起作用 导入pymongo client=pymongo.MongoClient(“mongodb+srv://Debaditya:@pycluster.d6kvk.gcp.mongodb.net/?retryWrites=true&w=mailty”) db=client.test 命令(“createUser”,“sample”,roles=[“read”])

Python 我编写了一个pymongo脚本来添加示例用户,但它不起作用 导入pymongo client=pymongo.MongoClient(“mongodb+srv://Debaditya:@pycluster.d6kvk.gcp.mongodb.net/?retryWrites=true&w=mailty”) db=client.test 命令(“createUser”,“sample”,roles=[“read”]),python,Python,请帮助我上面给出了代码以下是在集合中插入文档的示例代码 import pymongo client=pymongo.MongoClient("mongodb+srv://Debaditya:<password>@pycluster.d6kvk.gcp.mongodb.net/<db>?retryWrites=true&w=majority") db = client.test db.command("createUser",

请帮助我上面给出了代码

以下是在集合中插入文档的示例代码

import pymongo
client=pymongo.MongoClient("mongodb+srv://Debaditya:<password>@pycluster.d6kvk.gcp.mongodb.net/<db>?retryWrites=true&w=majority")
db = client.test
db.command("createUser", "sample", roles=["read"])
from pymongo import MongoClient
client = MongoClient("mongodb+srv://Debaditya:<password>@pycluster.d6kvk.gcp.mongodb.net/<db>?retryWrites=true&w=majority")
db = client.test
db.students.insert_one({"name": "Test User", "rollNo": 37})

刚看完pymongo的文件

list(db.students.find())