2012-04-20 6 views
3

--uid와 같은 명령 줄 인수 user_id가 있습니다.mongo query in python

파이썬의 다른 "student_details"컬렉션에서 특정 user_id의 레코드에 액세스하려고합니다. 내가 MongoDB에 새로운 오전으로

, 나는 나의 특정 쿼리에

users={ 
_id :Object(###), 
name:"", 
standard:"" 
.. 
.. 
.. 
} 


student_details={ 
_id:Object(###), 
user_id:"", -----> referenced 
.. 
} 

내가이 일을 시도에 대한 답을 좀하고 싶습니다

collection = db['student_details'] 
query = "%s" % option.uidfile 
results = collection.find({"user_id":query}) 

print results 

OUPUT :

<pymongo.cursor.Cursor object at 0x95c910c> 

미리 감사드립니다.

+0

아마 등 일부 코드, 테이블 구조를 제공? I 이러는 시도 – McGarnagle

답변

3

현재 튜토리얼
http://api.mongodb.org/python/2.0/tutorial.html
을 살펴해야하지만 수집 "student_details"을했다 파이썬에서 열린 경우는 쿼리 것 :

collection.find({"userID" : user_id}) 
+0

, 수집 = DB를 [ 'student_details'] 쿼리 = 결과 option.uidfile "% S"% = collection.find ({ "USER_ID"쿼리}) 결과의 I : 인쇄하다 – Ankita