5

When I try saving a dict with a '.' in the key PyMongo throws an error (InvaildName) however I do see (on the Mongodb website) that keys can have '.''s in them. Why is it that pymongo won't let me save these docs? Is there an issue with them and Mongo?

James

user319723
  • 451
  • 1
  • 5
  • 8
  • You can use a SONManipulator - see example in http://stackoverflow.com/questions/8429318/how-to-use-dot-in-field-name – Ziad Sawalha Dec 20 '13 at 08:22

2 Answers2

12

Where are you seeing an example of documents with "." in a key name? Those are invalid in MongoDB (hence PyMongo's restriction).

The reasoning is that we use dot notation in queries to reach inside of embedded documents.

mdirolf
  • 7,521
  • 2
  • 23
  • 15
1

You can use the dot in updates and finds, but not in save/insert.

eckberg
  • 66
  • 3