Search This Blog

Thursday, December 19, 2013

Connect pymongo to bottle framework

Important note: This article is in relation to online MongoDB course. For more information about the course and other posts describing its content please check my main page here: M101P: MongoDB for Developers course

Install software
aptitude install git
aptitude install gcc
aptitude install python-dev
aptitude install python-pip
pip install pymongo
pip install bottle
view raw instalation hosted with ❤ by GitHub
Testing

# extract the hw1 archive file
# change to the directory
$ ls
root@mongo2:~/hw1# ls -la
total 24
drwxrwxr-x 3 root root 4096 Dec 18 23:57 .
drwxr-xr-x 11 root root 4096 Dec 18 23:57 ..
drwxr-xr-x 3 root root 4096 Feb 12 2013 dump
-rw-r--r-- 1 root root 598 Mar 27 2013 hw1-2.py
-rw-r--r-- 1 root root 2584 Dec 18 23:51 hw1-2.py.html
-rw-r--r-- 1 root root 745 Dec 18 23:57 hw1-3.py
$ mongorestore
$ mongo
> show dbs
> show collections
> use m101
> db.funnynumbers.find().sort( {value:1 } )
{ "_id" : ObjectId("50778ce69331a280cf4bcfa2"), "value" : 0 }
{ "_id" : ObjectId("50778ce69331a280cf4bcfbe"), "value" : 0 }
{ "_id" : ObjectId("50778ce69331a280cf4bcf8f"), "value" : 1 }
{ "_id" : ObjectId("50778ce69331a280cf4bcfb2"), "value" : 1 }
{ "_id" : ObjectId("50778ce69331a280cf4bcfc0"), "value" : 2 }
{ "_id" : ObjectId("50778ce69331a280cf4bcfda"), "value" : 2 }
> db.hw1.find()
{ "_id" : ObjectId("50773061bf44c220307d8514"), "answer" : 42, "question" : "The Ultimate Question of Life, The Universe and Everything" }
> db.funnynumbers.drop()
> db.dropDatabase()
{ "dropped" : "m101", "ok" : 1 }
view raw mongo_shell hosted with ❤ by GitHub
References

http://docs.mongodb.org/manual/reference/method/db.collection.find/#db.collection.find

No comments:

Post a Comment