This repo contains course notes and Mflix project in Intro to MongoDB course from MongoDB Inc. on Coursera.
-
Created a mongo atlas free account. Project: analytics, cluster: mflix. set name and pwd, whitelist address 0.0.0.0/0
-
Installed mongo on my computer using this instructions:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
-
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
-
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
-
sudo apt-get update
-
sudo apt-get install -y mongodb-org
-
Download CSV file from the OMDB movies dataset. "It is nice because it is large enough and requires enough data cleaning to be realistic". Load it into mongo. The API changed so this worked for me (most of the info was in atlas->connect->mongo shell):
mongoimport --uri "mongodb+srv://<PROJECT>:<PROJECT-PWD>@mflix-d8wrg.mongodb.net/mflix?authSource=admin" --type csv --headerline --ssl movies_initial.csv
-
Downloaded and installed compass. Go to atlas->connect->compass, copy string and compass will detect automatically. fill with pwd. And in favorite set: Analytics Free-Tier. Connect and explore data.
-
Connect from a python application:
pip install pymongo
. Alsopip install dnspython
MongoDB Atlas: Cluster that provides MongoDB hosting service
Check out https://www.mongodb.com/cloud/atlas
Play around with MongoDB Atlas:
-
Import data to MongoDB Atlas
$ cd mflix $ mongoimport --type csv --headerline --file movies_initial.csv --host "Cluster0-shard-0/cluster0-shard-00-00-hanbs.mongodb.net:27017,cluster0-shard-00-01-hanbs.mongodb.net:27017,cluster0-shard-00-02-hanbs.mongodb.net:27017" --db mflix --collection movies_initial --authenticationDatabase admin --ssl --username <username> --password <password>
$ pipenv --python=3.7
$ pipenv shell
# Install all the packages specified in Pipfile
$ pipenv install
-> GUI client for MongoDB
Check out https://www.mongodb.com/products/compass
Check out the demo files for:
Function | Aggregation |
---|---|
Filtering | $match |
Aggregation | $group , $sortByCount , $bucketAuto |
Parallel pipeline processing | $facet |
Projection | $addFields , $project , $cond |
Post-processing | $sort , $limit , $skip , $out |
Check out mflix
folder, which is the root directory of Mflix project