M220P: Frequently Asked Questions

1. Which version of Python should I set up this course with?

The course has been tested with Python 3.8 and it is recommended to take this course with this version.

2. Where is the connection string that I need to put in the .ini file in Ticket: Connection?

Kindly follow the given steps to obtain the connection string:

Step1: Make sure to create your user credentials, with the privilege to read and write to any database in Atlas as instructed in the Lab (Ungraded): Create or Reuse Atlas Cluster:

  • username: m220student
  • password: m220password

Step2: In Atlas, click on Connect

Step3: Click on Connect your Application. Choose Python as Driver and any latest version. Copy the connection string. Add your username and password in the string and paste them into the .ini file.

As mentioned in the lab instructions, do make sure that your string looks like this:


3. How is the string we paste in the .ini file different from the string we use in the command line: mongodb+srv://mflix.mongodb.net/sample_mflix --username m220student --password m220password and why is it not working if I paste it into the .ini file?

The string like
mongodb+srv://mflix.mongodb.net/sample_mflix --username m220student --password m220password
is a list of parameters for a command-line tool like mongosh or mongodump. Please see MongoDB connection string URI for more information. 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 to be included in the connection URI:


This is also the string that one needs to use for this course. This connection string format works with drivers as well as command-line tools, so it is highly recommended to use this consistently. For more reference examples, please see Connect to your Atlas Cluster.

4. Facing issues in the ticket: Migration

During this Ticket, if you got any error or are not able to understand why it is not working, please verify the following points:

  1. You need to run the migration script from the main directory mflix-python. Otherwise, the config parameters like cluster URI and database name won’t be able to map.
  2. Also, verify the data type in the dataset of the lastupdated field. It should be a still string. Sometimes, when trying to make the script work, we mistakenly update the dataset with the wrong data type, so it will prevent running the script further. as we are adding predicate with type: string in the query.
  3. Always check the error message carefully, after running the script, take a screenshot for sharing it in the forums or debugging it.

5. Unable to pass tests or get Validation Code in Create/Update Comments.

For this ticket, kindly make sure your code satisfies the following:

  1. the comments returned in the mongo doc by get_movie() function are sorted in descending order by date.
  2. movie_id in add_comment() gets converted to ObjectId.
  3. comment_id in update_comment() and delete_comment() is also converted to ObjectId.

6. How to add a new user in the Principle of Least Privilege ticket / I added a new user in the Principle of Least Privilege ticket and yet failed the lab.

For this ticket, to create a new user, kindly follow these steps:

Step1: Click on the Database Access tab in Atlas followed by Add New Database User.

Step2: Select Password as the Authentication mode. Enter the user credentials as mentioned in the lab ie.

  • username: mflixAppUser
  • password: mflixAppPwd

In Database user privileges, select Specific Privileges and enter the role and database as mentioned in the lab.

Once all this is done, click Add User.

Step3: After you have created this user, modify the SRV connection string in your configuration file so the application connects with the new username and password.

Step4: Restart the mflix app (ie. close your terminals/app and then re-start the app). Your app should now be connecting this new user and you should be able to pass the ticket.

In case you have doubts, please feel free to reach out to us.

Thanks & Regards,

1 Like