/python-mongodb

This is an example on how to connect Python with MongoDB

Primary LanguagePythonMIT LicenseMIT

Python + Mongo

On this tutorial we will create an API using Python 3 and MongoDB

Requirements

Getting Started

  1. Create a Python Virtual Environment.
pip3 install virtualenv
virtualenv -p python3 my-vir-env-py-mon
  1. Activate and go inside your Virtual Environment
source my-vir-env-py-mon/bin/activate
cd my-vir-env-py-mon
  1. Clone this project
git clone https://github.com/arturoaviles/python-mongodb
cd python-mongodb
  1. Install dependencies
pip install -r requirements.txt
  1. Make a copy of the env.sample to .env
cp env.sample .env
  1. Configure the .env with your MongoDB Credentials
DATABASE=Your_DB_Name
PASSWORD=Your_DB_Pass
  1. Run Mongo

Make sure to run in a terminal:

mongod

And then in another (If you want to interact with the DB direclty):

mongo
  1. Run the API
python server.py

More Tutorials

License

This sample code is licensed under MIT Full license text is available in LICENSE.