Showing posts with label MongoDB. Show all posts
Showing posts with label MongoDB. Show all posts

Thursday, February 13, 2014

Install MongoDB on Ubuntu

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

$ echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
$ sudo apt-get update

$ sudo apt-get install mongodb-10gen

$ mongo --version

Friday, June 21, 2013

node.js Notes

Good advice re: learning node.js is here.


$ npm shrinkwrap   is like   $ pip freeze   Explanation here.


Connecting to local mondoDB server or a cloud mongoDB is simply a matter of creating the connection URL properly. Do A or B below.

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var url;

module.exports.mongoose = mongoose;
module.exports.Schema = Schema;

// (A) Connect to cloud database (like mongolab)
var username = "user";
var password = "password";
var address = '@dbh42.mongolab.com:27427/nockmarket';
url = 'mongodb://' + username + ':' + password + address;
connect(url);

// (B) Connect to DB called chapter1 on local mongoDB server
url = 'mongodb://localhost/chapter1';
connect(url);

// Connect to mongo
function connect(u) {
  mongoose.connect(u);
}

function disconnect() {mongoose.disconnect()}


Monday, June 17, 2013

Working with node.js

Show installed packages in node.js

$ npm list

Install mongodb driver for node.js

$ npm install mongodb

Install Mongoose

$ npm install mongoose




Wednesday, May 29, 2013

Tuesday, May 28, 2013

stockticker (flask/mongodb) on Heroku

Creating an App

1. Create ~/.gitconfig (if not already there)

$ git config --global user.name "My Name"
$ git config --global user.email emailname@mailhost.com

2. Set-up Project Specific Development environment:

$ mkdir ~/dev/stock-fh
$ virtualenv venv
$ work stock-fh
$ git init
$ gedit .gitignore
$ gedit README.md
$ git add .
$ git commit -m "initial commit"
$ mkdir static static/css static/js static/img static/ico templates

create favicon.ico file at favicon.cc and add to static/ico

add any necessary css, js, and img files, html goes in templates dir


3. Go to bitbucket.org and create a new repo called stock.fh and then:

$ git remote add origin ssh://git@bitbucket.org/gbiglow/stock-fh.git
$ git push -u origin --all

4. install required python components and generate requirements.txt

$ pip install flask
$ pip freeze > requirements.txt
$ git add requirements.txt
$ git commit -m "added initial requirements.txt"
git push origin master

5. create a Procfile for heroku and foreman

$ echo "web: python app.py" > Procfile
$ git add Procfile
$ git commit -m "added initial Procfile"
$ git push origin master

6. Create heroku app (this also creates a heroku remote for git)

$ heroku create stock-fh
git push heroku master

7. use mongoDB on heroku




todo:
  • pip add pymongo etc. update requirements.txt
  • twitter bootstrap
  • investigate flask app generator. code. (possible automation of steps 2-6 above into a single command. hmm...

Notes:
  • This is all based on this great article.
  • The command 'work' (above) is a local script to activate a virtualenv
  • I use bitbucket rather than github as bitbucket has unlimited private repos as part of a free account.









Monday, May 13, 2013

Install MongoDB on Linux Mint 14

Install MongoDB on Linux Mint 14 or 15 Cinnamon 64 bit


Follow steps on mongoDB page to install mongo.


Configure MongoDB
These packages configure MongoDB using the /etc/mongodb.conf file in conjunction with the control script. You will find the control script is at /etc/init.d/mongodb.
This MongoDB instance will store its data files in the /var/lib/mongodb and its log files in /var/log/mongodb, and run using the mongodb user account.


Starting MongoDB
You can start the mongod process by issuing the following command:
sudo service mongodb start
You can verify that mongod has started successfully by checking the contents of the log file at /var/log/mongodb/mongodb.log.
Stopping MongoDB
As needed, you may stop the mongod process by issuing the following command:
sudo service mongodb stop
Restarting MongoDB
You may restart the mongod process by issuing the following command:
sudo service mongodb restart



Wednesday, May 1, 2013

Robomongo - gui admin tool for Mongo

Robomongo is a GUI cross platform Mongo admin tool alternative to the basic mongo shell.
Worth a look...

Saturday, April 20, 2013

MongoDB Training

Great FREE MongoDB training @ https://education.10gen.com

You may need to wait until the specific course you want is scheduled but it is worth the wait.
Quality training for the right price.

A free into to MongoDB is available in the following ebook:
http://openmymind.net/2011/3/28/The-Little-MongoDB-Book/

Read about PyMongo if you want to use MongoDB with Python.