Lets get started with pymongo

Hi everyone

Mongodb is simply a nosql database structure, used for handling huge data.

Pymongo is the driver used for using mongo db with python.

Installation

                                pip install pymongo

The above command will install pymongo in a linux based system.

Usage

# It's simply a python file which uses pymongo 
# driver to interact with mongo db.
# Following code imports mongoclient from pymongo 
from pymongo import MongoClient

# The following code initialises the mongoclient 
client = MongoClient()

# To use a perticular database use the following code.
db = client['test']

# collection is like tables in database. 
# define a collection and start using it.
collection = db['new_collect']

Note: Mongo db is simply a nosql database. you can create schema you can have large data in it.
It uses Bson as it’s datatype. Bson is binary Json. and data is stored as bson only.

It’s much faster and not dependent on the structure of models. It’s simply great.

I will be back with crud operations soon, till then enjoy this awesome nosql.

Leave a comment