MongoDB对象指向

时间:2014-11-02 18:11:23

标签: database-design mongodb python

我正在做一个网络应用程序,我有一个疑问。我需要获得MongoDb JSON的值吗?宾语。我发布了我的代码.. import pymongo try: conn =pymongo.MongoClient('localhost') print('Conexion realizada:') except pymongo.errors.ConnectionFailure, e: print('No se ha podido realizar la conexion: %s' % e) db = conn.test coll = db.puntos print(list(coll.oxigeno.find())) <-- I want to print the Oxigeno value of the Objct

非常感谢你

1 个答案:

答案 0 :(得分:0)

当您说要打印对象的Oxigeno值时,不确定您想要什么,但是要在查询结果中打印文件的oxigeno值,请执行

for doc in coll.find():      # .find() returns cursor which is meant for iteration
    print(doc["oxigeno"])    # doc is a python dictionary representing the returned BSON document