Search code examples
pythonpython-3.xpymongomongoengineflask-mongoengine

Can mongoengine run raw query in python?


In pymongo,I can run raw query like this:

 conn = pymongo.MongoClient("mongodb://" + mongo_url)
 db = conn[db]
 db.authenticate(username,password)
 coll = db["coll_name"]
 coll.find(raw_query)

How can I do that in mongoengine without creating a Document class?


Solution

  • mongoengine.connect returns a client so maybe you can do the same just replacing the first line with conn = mongoengine.connect().