GithubHelp home page GithubHelp logo

itp-review's Introduction

MongoDB library - Mongoengine

Mongoengine

Adding Mongoengine to requirements.txt

Mongoengine==0.7.5
unidecode

Getting Started with MongoDB on Heroku

We will be using MongoLabs as our MongoDB host service, they have a free starter plan that we can easily associate with our Heroku accounts. When we have added the MongoLabs service we will have a connection string that includes username, password and URI to the database server.

Step 1 : Download code, setup Git, heroku create

  1. Download the sample code from Github

  2. Navigate to code directory in Terminal. Create Git repo

     git init
     git add .
     git commit -m "initial commit"
    

    Create virtual environment and install requirements

     virtualenv venv
     . runpip
    
  3. Create a new Heroku app

     heroku create
    

Step 2 : Adding MongoLabs to your Heroku App

Heroku offers a lot of different Add-ons for your apps. Many different types of databases, image tools, cache utilities are available from 3rd party companies. Many offer a trial plan to test and develop with before you commit to a paid plan.

MongoLabs offers a 250MB MongoDB instance for free (see here) : ) How wonderful.

To install the MongoLabs

  • Navigate to the code folder of your app

  • In Terminal, add the MongoLab starter plan

      heroku addons:add mongolab:starter
    

This has added MongoLab to your app.

Step 3: Configure your local environment

When adding Add-ons, Heroku will add the required configuration variables for the services including username, password, urls, etc.

We must create a local configuration file to allow our local development server to connect to the MongoLabs MongoDB instance. We can grab a copy of our Heroku configuration variables and put them inside a .env file, our environment variable file.

Run the following command inside your code folder.

heroku config --shell > .env

This will create a new file, .env and it will contain a single line starting with MONGOLAB_URI and followed by a long connection url. This is the username and password for your MongoLabs account.

.env

MONGOLAB_URI=mongodb://heroku_app8083291:sadlfkweweroi........

Step 4: Add .env to .gitignore file

We want GIT to ignore the .env file, VERY IMPORTANT This keeps our environment variables safe and they won't get included inside our GIT repository (or worse, get pushed to Github).

Open your .gitignore file and add '.env' on a new line. Save the file.

.gitignore

.env

Step 5: Start your servers

. start

or

foreman start

itp-review's People

Contributors

matthewepler avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.