[英]mongo query in python
I have a command line argument user_id as --uid. 我有一个命令行参数user_id为--uid。
I want to access the record of that particular user_id from another collection "student_details" in python. 我想从python中的另一个集合“student_details”访问该特定user_id的记录。
As I am new to mongoDB, I would like to get the answer for my particular query 由于我是mongoDB的新手,我想得到我的特定查询的答案
users={
_id :Object(###),
name:"",
standard:""
..
..
..
}
student_details={
_id:Object(###),
user_id:"", -----> referenced
..
}
I tried doing this, 我试过这样做,
collection = db['student_details']
query = "%s" % option.uidfile
results = collection.find({"user_id":query})
print results
ouput: 输出继电器:
<pymongo.cursor.Cursor object at 0x95c910c>
Thanks in advance. 提前致谢。
You should take a look at the tutorial here 你应该看看这里的教程
http://api.mongodb.org/python/2.0/tutorial.html http://api.mongodb.org/python/2.0/tutorial.html
But if you had collection "student_details" opened in python you would query: 但是如果你在python中打开了集合“student_details”,你会查询:
collection.find({"userID" : user_id})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.