title: Get all documents of a collection using Pymongo
body: <p>I want to write a function to return all the documents contained in <code>mycollection</code> in mongodb</p>
  
  <pre><code>from pymongo import MongoClient
  
  if __name__ == '__main__':
      client = MongoClient("localhost", 27017, maxPoolSize=50)
      db=client.mydatabase
      collection=db['mycollection']
      cursor = collection.find({})
      for document in cursor:
          print(document)
  </code></pre>
  
  <p>However, the function returns: <code>Process finished with exit code 0</code></p>