mongo

what is mongo

MongoDB is NoSQL database, NoSQL = not only sql.

And from wikipedia:

The term NoSQL was used by Carlo Strozzi in 1998 to name his lightweight, Strozzi NoSQL open-source relational database that did not expose the standard Structured Query Language (SQL) interface, but was still relational.[16] His NoSQL RDBMS is distinct from the circa-2009 general concept of NoSQL databases. Strozzi suggests that, because the current NoSQL movement "departs from the relational model altogether, it should therefore have been called more appropriately 'NoREL',[17] referring to 'No Relational'.

MongoDB is document database:

  • not .PDF or .DOC/.DOCX
  • is a associative array
  • document == json object
  • document == php array
  • document == python dict
  • document == ruby hash

Why mongo

  • flexible schema
  • oriented toward programmers
  • flexible deployment
  • designed for big data

Install mongo

mac: brew intall mongo

Usage

We can use PyMongo to communicate with mongo in python.

Use pip install PyMongo command to install PyMongo.

And:

1
2
3
from pymongo import MongoClient
client = MongoClient('localhost:27017')
db = client[db_name]

So now we can use db to read/create/update/delete the data.