note: I am sorry if this is a stupid question!
I have this program that generates data that it stores in pythons dictionaries.
Since this is getting bigger and bigger, and since this is not persistent and the program has to create them all over again, each time it runs....
I tried to use mongodb, but it seems to need both key and value to search(find function). But I have only the key, and I need the value.
How is this done?
Store each dictionary entry (key, value pair) as a separate document in mongo {key: "keyval", value: "valueval"}
and provide only the key to the find function:
mydocs.find({'key': something}, fields=['value'])
If the collection is large, you'll need to add an index on key
:
mydocs.ensure_index('key')
db.collectionName.ensureIndex({"key" : 1});
lollercoaster 2013-06-27 15:21
ensure_index
too - Vignesh 2012-04-06 11:46