mongodb - How to get values of cursor object by using Python -
i have data in mondodb;
db.np_tpy_gla.find({},{"_id":0, "c": 1}) result:
{ "c" : numberlong(18) } { "c" : numberlong(40) } { "c" : numberlong(42) } { "c" : numberlong(54) } ... i trying these values using python (pymongo). here code:
counternumber = cursor.count() gettingtotalsize = cursor.find({"c": true}) print counternumber print gettingtotalsize and here result:
115 <pymongo.cursor.cursor object @ 0x13c7890> i'm tring "gettingtotalsize" values 1 one.
how can these values? tried loop.
thanks.
edit :
i changed codes like:
gettingtotalsize = cursor.find({}, {"_id": 0, "c": 1}) vignesh kalai'codes:
for x in gettingtotalsize : print x here new result :
{u'c': 18l} {u'c': 40l} {u'c': 42l} {u'c': 54l} ... now need value (18,40,42,54...)
any ideas? :)
to iterate on cursor loop on cursor , element out of dictionary pass it's key value
code:
for x in gettingtotalsize : print x["c"]
Comments
Post a Comment