M220P Chapter 0 Ticket

I need some help…
I am running the pytest -m connection command and I am getting a bad database name error.

I have installed mongosh using homebrew

I have added my connection string according to the connect with shell method.

My .ini file contains

# Ticket: Connection
# Rename this file to .ini after filling in your MFLIX_DB_URI and your SECRET_KEY
# Do not surround the URI with quotes

SECRET_KEY = super_secret_key_you_should_change
MFLIX_DB_URI = mongodb+srv://mflix.bcxn7.mongodb.net/sample_mflix --username m220student --password m220password
MFLIX_NS = sample_mflix

SECRET_KEY = super_secret_testing_key
MFLIX_DB_URI = mongodb+srv://mflix.bcxn7.mongodb.net/sample_mflix --username m220student --password m220password
MFLIX_NS = sample_mflix

My question is that the connection string in atlas uses myFirstDatabase… Is this supposed to be changed to sample_mflix, or admin?

Also… atlas only shows the username… is it proper to use the --username m220student --password m220password?

I am familiar with -u and -p…

Ok… I just checked my mongosh version by running mongosh --version.
It says I am runing 1.1.9…
Do I need to install mongodb to get the latest version?

(mflix) davethompson@Davids-iMac-2 mflix-python % mongosh --version
(mflix) davethompson@Davids-iMac-2 mflix-python % 

Your uri string is not in the expected format
I think already answered by Satyam Gupta in another thread M220P initial setup

Hi @David_Thompson,

As @Ramachandra_Tummala noted (and I believe this has been discussed in one of your related threads), the issue is that you are not providing a valid connection string in your .ini file.

mongodb+srv://mflix.mongodb.net/sample_mflix --username m220student --password m220password

This string is a list of parameters for a command line tool like mongosh or mongodump: MongoDB connection string URI, username, and password. Command tools have alternative ways to provide options (like --username or --password) as those might be easier to remember or require interactive prompts (for example, to enter your password).

A driver or tool like MongoDB Compass will only support a connection string URI. If you want to use additional parameters like username and password, they have be included in the connection URI:


The connection string format works with drivers as well as command-line tools, so I recommend using this consistently.

For more reference examples, please see Connect to your Atlas Cluster.


1 Like


Thank you for your response… I was using the connection string you mentioned but it wouldn’t work (pytest -m connection would not pass).

I changed it to the following:


once I used this connection string, the pytest -m connection passed and I was able to complete the ticket on my desktop… I am now trying to duplicate this on my MacBook Pro so I can be mobile and I cannot get the browser to display the status page. (sample_mflix)

The pytests pass, but I cannot get the browser to display.

I also feel it is important to point out that the connection string is not very well explained… There are SEVERAL different versions of it and you kinda got to experiment to get the right one. And when to change / what differences in the string you need are not explained real well…

The string you mentioned uses key:value pairs… According to the connection string that I am currently using (again pytest -m connection passes) looks exactly like the example on the ticket… Where I may be confused is in the atlas cluster address… I am using the string that looks nothing like the atlas connection directions…

As you can see… The connection string shown in atlas looks nothing like the connection string that is in the ticket… I think that this causes a lot of confusion.

Hi @David_Thompson,

The connection example you have selected in your screenshots is for connecting with the mongo shell. The description in the UX could be improved as the “Use this connection string in your application” example is really “Run this command-line in your O/S shell”.

In your second screenshot you need to choose the option to “Connect your application” in order to get the connection string to use with an application or driver like PyMongo.


@Stennie ,
I was wondering that. LOL. thanks

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.