We are moving away from MongoDB shell to Python, where we are interacting with the MongoDB database with scripts.
Do you still remember how we were scraping web sites? MongoDB is an excellent choice for storing such data because web pages are unstructured data that can be parsed into a NoSQL database.
Introduction to PyMongo
Let’s open up the file(s) in the 01-Ins_PyMongo
folder to get started.
Installing PyMongo
- Activate your dev environment on conda:
conda activate dev
- To install PyMongo into your dev environment, type:
conda install -c anaconda pymongo
- To check if your PyMongo is installed, type:
conda list pymongo
Students Do: Mongo Class
Let’s open up the file(s) in the 02-Stu_MongoClass
folder to get started.
PyMongo with Imported CSV Data
Let’s open up the file(s) in the 03-Ins_PyMongo_with_Imported_Data
folder to get started.
To import the CSV customer dn from your directory into a Mongo database, type:
mongoimport --type csv -d petsitly_marketing -c customer_list --headerline --drop customer_database.csv
Students Do: PyMongo with Imported JSON Data
Let’s open up the file(s) in the 04-Stu_CreateMongoDatabase
folder to get started.
Importing Data, Accessing Nested Data, and Modifying Data Types
Let’s open up the file in the 05-Ins_SelectingFields
folder to get started.
mongoimport --type json -d autosaurus -c mechanics --drop --jsonArray mechanics.json
mongoimport --type csv -d autosaurus -c customers --headerline --drop customers.csv
Students Do: Air Fields
Let’s open up the file(s) in the 06-Stu_AirFields
folder to get started.
Comparison Operators
Let’s open up the file(s) in the 07-Ins_ComparisonFilters
folder to get started.
Students Do: Find Pets
Let’s open up the file(s) in the 08-Stu_FindPets
folder to get started.
Sort and Limit
Let’s open up the file(s) in the 09-Ins_SortAndLimit
folder to get started.
Students Do: Sort and Limit Pets
Let’s open up the file(s) in the 10-Stu_SortAndLimitPets
folder to get started.