This project demonstrates the use of MongoDB with Python to manage and analyze movie data. It includes functionality to import movie information from CSV and JSON files, perform various database operations, and execute advanced queries using MongoDB's aggregation framework.
mongo-project.py
: Main script to run the projectmongo-project.conf
: Configuration file for database connectionmodules/db.py
: Database connection and configuration handlingmodules/movies.py
: Movie-related operations and queriesmodules/csv_util.py
: Utility for reading CSV filesmodules/json_util.py
: Utility for reading JSON filesdata/movie_info.csv
: Sample movie data in CSV formatdata/movie_info.json
: Sample movie data in JSON format
-
Ensure you have MongoDB installed and running on your system. (You can use brew services to download mongodb, and after the activation; use
mongosh
code in your terminal to run mongodb shell.) -
Install the required dependencies:
pip install -r requirements.txt
or if you would like to install it manually;
pip install pymongo configparser
-
Clone this repository to your local machine.
-
Navigate to the project directory.
-
Run the main script:
python mongo-project.py
- The script reads the configuration file (
mongo-project.conf
). - It establishes a connection to the MongoDB database.
- Movie data is read from CSV and JSON files.
- The data is inserted into the MongoDB collection.
- Various queries are executed to demonstrate MongoDB operations and aggregations.
- Special thanks to Prof. Rahim Virani for teaching the configuration and general structure of the process during my education at Douglas College.
- This project uses the
pymongo
library to interact with MongoDB. - Sample movie data is sourced from Rotten Tomatoes (for educational purposes only).