LionelF
LionelF

Reputation: 147

Extract only value result find request from mongodb

i want to extract only the value from the domain document

import socket
from pymongo import MongoClient



client = MongoClient()
db = client.my_domains
collection = db.domain
document = collection.find({},{'domain': 1, '_id':0})


for d in document:
    print(d)

Result is :

{u'domain': u'301udns.info'}
{u'domain': u'idcay.com'}

How can extract only the value like 301udns.info for my example. Thank you in advance for your answer.

Upvotes: 1

Views: 338

Answers (1)

P.Madhukar
P.Madhukar

Reputation: 464

for d in document:
    print (d['domain'])

Upvotes: 1

Related Questions