[英]Cannot read docs, inserted into mongodb using pymongo, with mongo shell
I am running the following code in python 3.4 我正在python 3.4中运行以下代码
import pymongo
conn = pymongo.MongoClient()
db1 = conn["db1"]
movie = {"name": "Avengers", "year": 2012}
db1.movies.insert(movie)
conn.close()
When i am trying to read the doc in mongo shell using the following commands, it just returns nothing. 当我尝试使用以下命令在mongo shell中读取doc时,它什么也不返回。
use db1
db.db1.movies.find()
no need to call db.db1
just use db
无需调用db.db1
只需使用db
use db1
db.movies.find()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.