Here's how to connect to Atlas MongoDB

  • Installing FireWorks still suggests, “Set up an account via the mLab web site instructions…” but that should be removed now since mLab no longer allows new accounts.
  • It also suggests MongoDB Atlas but doesn’t document how to set up FireWorks with Atlas. That’s tricky because Atlas creates a server cluster rather than a single server. Having figured it out, I’ve documented how, below.
  • The lpad init command (without -u) asks for a host parameter like 'localhost' or 'mongodb+srv://CLUSTERNAME.mongodb.net' but I did not succeed in getting that to work with Atlas. If there’s a way, the steps below could be simpler.

How to configure FireWorks to connect to MongoDB Atlas

On the Atlas website

  1. Create an account at https://cloud.mongodb.com/ with a strong password (this account will be accessible on the open Internet).
  2. Create a free cluster, name it, and add a database “fireworks”.
  3. Add a database user with a strong password and give it “Atlas Admin” user privileges.
  4. Set “Network Access” to Allow Access from your IP range (or from Anywhere, 0.0.0.0/0).
  5. Under Clusters > CONNECT, click Connect your application and pick the “driver” “Python x.y or later” corresponding to your pymongo pip version x.y.
  6. Copy the connection URI, e.g.
    mongodb+srv://DBUSERNAME:<password>@cluster1.6wxyz.azure.mongodb.net/<dbname>?retryWrites=true&w=majority.

On your computer

  1. pip install dnspython # needed to access a mongo cluster
  2. Compute the URL-quoted DB user’s password:
    python -c "import urllib.parse; print(urllib.parse.quote('DB USER PASSWORD'))"
  3. Create my_launchpad.yaml, assembling parts of the connection URI with step 2:
    lpad init -u
    Enter host parameter: mongodb+srv://DBUSERNAME:[email protected]/fireworks
    Enter ssl_ca_file parameter:
    Enter authsource parameter: admin
    
  4. lpad reset

I hope this helps. Thanks all your contributions, people!

3 Likes
  • mlab.com MongoDB servers will shut down after December 08, 2020.
  • I guess we should add the ?retryWrites=true&w=majority part to the host URL. (Are those parameters set already by default?)