mongodb - Pymongo importing succeeded but not showing in the collection -
i tried importing json file 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 tried viewing it, not there
from pymongo import mongoclient client = mongoclient('localhost',27017) db = client['dbwhy'] coll = db['dbcol'] curs = db.coll.find() in curs: print(i) it not show anything
the problem here:
db.coll.find() this find documents inside coll collection, your collection named dbcol.
instead, use coll variable you've defined:
from pymongo import mongoclient client = mongoclient('localhost',27017) db = client['dbwhy'] coll = db['dbcol'] curs = coll.find() # fix here in curs: print(i)
Comments
Post a Comment