marcus kielly
2012-11-05 23:09:07 UTC
Hi, - I know this is a fairly common problem. I'm writing a small Flask app
and I'm trying to feed some queries back to the view.
I've connected to my local MongoDB setup, and made a successful query - but
I can't generate a json object with it.
The most common solution I've seen is to import json_util from pymongo i.e.
*
*
*import json*
*from pymongo import json_util*
*
*
*results = connection.get_collection('papayas_papaya')*
*results = results.find({*
* 'identifier': '1',*
*})*
*serialized_results = [json.dumps(result, default=json_util.default,
separators=(',', ':')) for result in results]*
I've installed pymongo into my Flask virtualenv using pip i.e :
*pip install pymongo*
When running the above code I keep getting the following error:
*ImportError: cannot import name json_util*
I can see this line in the *pymongo-2.3-py2.6.egg-info/installed-files.txt*
*../bson/json_util.py*
*
*
Anyone got any tips that can help me figure out what I'm doing wrong?
and I'm trying to feed some queries back to the view.
I've connected to my local MongoDB setup, and made a successful query - but
I can't generate a json object with it.
The most common solution I've seen is to import json_util from pymongo i.e.
*
*
*import json*
*from pymongo import json_util*
*
*
*results = connection.get_collection('papayas_papaya')*
*results = results.find({*
* 'identifier': '1',*
*})*
*serialized_results = [json.dumps(result, default=json_util.default,
separators=(',', ':')) for result in results]*
I've installed pymongo into my Flask virtualenv using pip i.e :
*pip install pymongo*
When running the above code I keep getting the following error:
*ImportError: cannot import name json_util*
I can see this line in the *pymongo-2.3-py2.6.egg-info/installed-files.txt*
*../bson/json_util.py*
*
*
Anyone got any tips that can help me figure out what I'm doing wrong?
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb