I'm having a strange issue with Pymongo's find_one function. I have a db called "cluster_db" hosted on my local machine. It has a collection called 'clusters'. When I run the query in the mongo shell I get following output.
> db
cluster_db
> db.clusters.findOne({_id:-8488068664808428000})
{
"_id" : NumberLong("-8488068664808427924"),
"members" : [
{
"participationCoeff" : 1,
"tweetID" : NumberLong("-8488068664808427924")
}
]
}
>
Now, during my code initialization phase I have a constant defined in a module 'dbutil' like this:
DB_CONNECTION = MongoClient('localhost', 27017)
CLUSTER_DB_HANDLE = DB_CONNECTION['cluster_db']
After this, within a function, I'm making following call.
dbutil.CLUSTER_DB_HANDLE.clusters.find_one({'_id':clusterID})
However, the above call always returns 'None'. If I go to MongoShell and run the exact same query with same clusterID, I see the result.
I know that it is a strange error, but somehow I'm not able to figure out as to why this is happening. Everywhere else, I'm being able to successfully make calls to 'clusters' collection in cluster_db using dbutil.CLUSTER_DB_HANDLE.clusters
_idof the returned document really not match the_idin thefindOne? - JohnnyHK