title: Download json file from MongoDB atlas with python
body: <p>I want to download the entire collection and put it into a json file. I've tried (see below) but it doesnt work.</p>
  <pre><code>import json
  from pymongo import MongoClient
  import pymongo
  from pathlib import Path
  
  myclient = MongoClient(&quot;mongodb+srv://&lt;DbName&gt;:&lt;DbPass&gt;@&lt;DbName&gt;.a3b2ai.mongodb.net/&lt;DbName&gt;?retryWrites=true&amp;w=majority&quot;)
  
  db = myclient[&quot;PlayerPrices&quot;]
  
  Collection = db[&quot;Playstation&quot;]
  
  payload = db.inventory.find( {} ) #I think this command is the problem
  with open(str(Path(__file__).parents[1]) + '\Main\playstation_1.json', 'r+') as file:
                  json.dump(payload, file, indent=4)
      
  </code></pre>