I got an error when inserting a document in Mongo using python.
document = {u'Status': 'Active',
u'Installation': {u'IsFrugal': True, u'IsFeatureSet': True, u'IsEvolving': True, u'IsAffordable': True},
u'AutoList': [u'IsFeatureSet', u'IsAffordable', u'IsFrugal']
}
TraceBack Error is
C:\Python27\lib\site-packages\pymongo-2.5.1_-py2.7-win32.egg\pymongo\collection.
py:357: RuntimeWarning: couldn't encode - reloading python modules and trying ag
ain. if you see this without getting an InvalidDocument exception please see htt
p://api.mongodb.org/python/current/faq.html#does-pymongo-work-with-mod-wsgi
continue_on_error, self.__uuid_subtype), safe)
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "D:\Office_Drive\RetailReco\contactsnew\rrpython\rcauto.py", line 28, in
<module>
rceval.AutoProcess()
File "C:\Python27\lib\site-packages\rrpython-0.1-py2.7.egg\rrpython\automizati
on.py", line 67, in AutoProcess
self._configdb[RCEVALPMTS].save(tempdict)
File "C:\Python27\lib\site-packages\pymongo-2.5.1_-py2.7-win32.egg\pymongo\col
lection.py", line 266, in save
return self.insert(to_save, manipulate, safe, check_keys, **kwargs)
File "C:\Python27\lib\site-packages\pymongo-2.5.1_-py2.7-win32.egg\pymongo\col
lection.py", line 357, in insert
continue_on_error, self.__uuid_subtype), safe)
bson.errors.InvalidDocument: Cannot encode object: True
"bson.errors.InvalidDocument: Cannot encode object: True"
When I using the "true" instance of True it works well, but it will insert a string value I want to add Boolean value, not a string.
When I trying to insert simple {"name": True}, it works well. How it is possible? What's going wrong?
Going by the stack trace, tempdict is likely the value True rather than a dictionary of data to be inserted due to a problem elsewhere in the application (such as the rrpython library).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With