TIMEX
TIMEX

Reputation: 271634

How come I can't insert into Mongo? It used to work

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.

Upvotes: 0

Views: 889

Answers (1)

dm.
dm.

Reputation: 2002

are you definitely hitting the same database ("testdb") in both cases? the default db in the shell is "test"

Upvotes: 1

Related Questions