A python project that creates MongoDB collections of NBA statistics and data fetched from stats.nba.com
The collections are designed to make advanced queries on teams or players as simple as possible.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
To install and use the project, you will need the following things:
Start by cloning the repository
git clone https://github.com/Bastien-B/nba-mongo.git
Create a python virtualenv in the repository
cd nba-mongo/
virtualenv venv
Activate your virtual environment and install the python packages dependencies
source venv/bin/activate
pip install -r requirements.txt
And this is it !
Before generating the collections, you should edit the configuration file of your database: database.cfg
This file provides information such as:
- host : the location of the MongoDB instance
- port : the TCP port on which the MongoDB instance listens for client connections
- db_name : the name of the database that will be created
- teams_collection : the name of the teams collection that will be created
- players_collection : the name of the players collection that will be created
First, you have to make sure that a MongoDB instance is up and running at the location:port that you provided in the database.cfg file.
For instance, on your local machine (by default localhost:27017)
mongod --dbpath /path/to/your/databases
Now, simply run the main script of the project
python main.py
The process takes about 20 mins, and once it is done, a new MongoDB database should be created, containing two collections:
- teams
- players
Success !
Here are some snapshots of the created collections, as seen on RoboMongo :
The project comes with several unit tests located in the nba-mongo/tests/ folder. The tests are compatible with python test discovery.
To run them all, go to the project folder and call discover from command line
cd nba-mongo/
python -m unittest discover
- Bastien Bessiere - Initial work - Bastien-B
This project is licensed under the MIT License - see the LICENSE file for details.