con = pymongo.Connection(MONGO_DOC_HOST, MONGO_DOC_PORT)
db = con.testdb
datasets = db.datasets
for post in db.datasets.find({"test_set":"xyz"}).sort("num_favs",pymongo.DESCENDING).limit(2):
print post #this works, and it prints fine!
post = {"hi":"abc"}
mongo_id = datasets.insert(post)
When I do datasets.insert
, and print out the mongo_id. The id prints!
However, when I do: db.datasets.find().count()
in the mongo console, the count is still the same...
Weird. When I do this in console..I get this error:
> db.datasets.insert({"gooder":"absdlk"})
E11000 duplicate key error index: fabletest.datasets.$flickr_original_1 dup key: { : null }
That's weird, I didn't index "gooder" at all.
are you definitely hitting the same database ("testdb") in both cases? the default db in the shell is "test"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.