I tried importing json file which succeeded
mongoimport --db dbwhy --collection dbcol --jsonArray consumer_complaint.json
2016-01-15T19:00:42.277-0600 connected to: localhost
2016-01-15T19:00:42.320-0600 imported 34 documents
but when I tried viewing it, it was not there
from pymongo import MongoClient
client = MongoClient('localhost',27017)
db = client['dbwhy']
coll = db['dbcol']
curs = db.coll.find()
for i in curs:
print(i)
It does not show anything
The problem is here:
This would find all documents inside the
coll
collection, but your collection is nameddbcol
.Instead, use the
coll
variable that you've already defined: