Sunday, December 16, 2018

MongoDB & Python

Python is an interpreted, high-level, general-purpose programming language used for many different types of applications within the development community and MongoDB is a NoSQL database which has become pretty popular throughout the industry in recent years. NoSQL databases provide features of retrieval and storage of data in a much different way than their relational database counterparts. 

In this blog I have share some basic examples, commands, Software used in process of interaction between MongoDB and Python,

Why You Should Use MongoDB?

The following are some of the MongoDB advantages:
  • Flexible schema – it maintains a hierarchical data structure
  • A large number of the MongoDB drivers and client libraries. MongoDB Drivers are used for connecting client applications and the database. For example, if we have a Python program and we want to connect it to MongoDB, we need to download and integrate the Python driver so that the program can work with the MongoDB database
  • Flexible deployment
  • The document-oriented storage (in the form of JSON style documents)
  • JavaScript as a language for querying
  • Dynamic querie
  • Index support
  • Profiling queries
  • Effective storing of large amounts of binary data, such as images and videos
  • Journaling operations of modifying data in the database
  • Supporting fault tolerance and scalability: an asynchronous replication, a replica set and a distributed database connected to the nodes
  • Can work in accordance with the MapReduce paradigm. MapReduce – a programming distributed computing model provided by Google that is used for parallel computing on a large, multiple petabytes, data sets in the computer clusters
  • Full-text search, supporting Russian language and morphological analysis
  • MongoDB supports horizontal scalability through sharding. Sharding is the process of storing data records across multiple machines. This approach is used in MongoDB to meet the data growth demands. As the size of the data increases, a single machine may not be sufficient to store the data nor provide an acceptable read and write throughput. Sharding solves the problem with horizontal scaling.
For decades, SQL databases used to be one of the only choices for developers looking to build large, scalable systems. However, the ever-increasing need for the ability to store complex data structures led to the birth of NoSQL databases, which allow a developer to store heterogeneous and structure-less data.

PyMongo

The official driver published by the Mongo developers is called PyMongo. This is a good place to start when first firing Python up with MongoDB. The first thing you’ll want to do is to install PyMongo in your environment which is done using PIP3



When you will run above command in shell it will load pymongo files in your environment. Once you are done with the setup, start your Python console and run the following command:


import pymongo

If it runs without raising any exception within the Python shell then your install worked just fine. If not, then carefully perform the steps again.

Create Database & Establishing a Connection

To create a database in MongoDB, start by creating a MongoClient object, then specify a connection URL with the correct IP address and the name of the database you want to create. MongoDB will create the database if it does not exist, and make a connection to it.
You can check if a database exist by listing all databases in your system:

Why it doesn’t have testDB which we just created? As you know MongoDB waits until you have created a collection (table), with at least one document (record) before it actually creates the database (and collection).  So let’s create a collection called "customers" and insert a record, or document into this collection



As you see created a dictionary object with name and address and inserted into collection “customers”. If it runs without raising any exception then it worked fine but to verify we can always print inserted id of document. Or you can use Robo Mongo to check if collection created with document or not, at my end after these commands execution Robo Mongo looks as follows


You can insert multiple documents using insert_many method



You can find all documents in Robo Mongo or run find command, when view documents in Robo Mongo it will look as follows



With find command in script using IDLE (Python 3.7 64-bit)



Output of script will be listing all documents of collection



Find document(s) with the address Vancouver




Find documents where the address starts with the letter "V":



Update Collection
You can update a record, or document by using the update_one() or update_many() method.



Delete Document
Delete the document with the address “Vancouver" using delete_one or delete_many





I have covered all crud operations using PyMongo and core is the MongoClient object. For more examples & method details you can refer Documentation at location https://api.mongodb.com/python/current/

MongoEngine

MongoEngine is Object-Document Mapper (ORM-like, but for document-oriented database) that allows to work with MongoDB on Python. To specify the schema document, we create a class that is inherited from the Document base class. Fields are determined from adding the document’s class attributes. You can install MongoEngine again using PIP as shown below



for demo purpose only I will create very common example class​ which is very basic script that’s will connect to mongo DB, Define document and document's schema of WikiPage with just title & description



If I open Robo Mongo I will see page1 & page 2 entered into wiki pages



For more examples & method details you can refer Documentation at location http://docs.mongoengine.org/  As Agreed Today I focused on Python & MongoDB interaction, next time I will share examples on Object-Oriented Programming in Python.

What do you think? Let me know your inputs & suggestions.

Courtesy: Several online blogs, you tube videos, tutorials & other resources

Friday, September 21, 2018

Agile Product Road-map


A road-map is every bit as important to an agile team as it is to a waterfall team because it provides context around the team's every-day work, and responds to shifts in the competitive landscape.

How an agile road-map differs from a waterfall road-map

A waterfall product road-map communicates a long-term commitment to building specific features on a set timeline. However, an agile road-map accommodates inevitable changes while still committing to getting meaningful work done. It communicates a short-term plan for achieving product goals, with the flexibility to adjust that plan according to customer value.

Here are some key ways that agile and waterfall road-maps differ:


Waterfall road-map
Agile road-map
Goals
Business-centric
Customer-centric
Planning horizon
Years
Months or quarters
Planning cadence
Annually
Quarterly
Resource / capacity planning
By major project
By small team
Investment
Committed
Incremental
Collaboration
Segmented
Cross-functional team
Flexibility
Limited
Limitless


Goals: Waterfall organizations often set business-centric goals, measured by financial KPIs. Agile organizations often set customer-centric goals, such as user growth and customer delight.

Planning horizon: A waterfall product road-map reflects commitments to a longer-term timeline — typically a year or two. And an agile road-map reflects quarterly (or even monthly) commitments.

Planning cadence: Waterfall organizations commonly do annual strategy and product planning. Agile organizations usually do it much more regularly in quarterly strategy and product planning cycles.

Resource / capacity planning: A waterfall road-map reflects heavy upfront dedication of resources, which are allocated by project. An agile road-map considers the sprint team the resource unit and can allocate by sprint velocity or team capacity.

Investment: Waterfall-driven products receive funding according to the organization’s annual planning cadence. These funds are committed for the year and are often based on the previous year. By contrast, agile-driven products can be funded incrementally as the organization adjusts its portfolio based on customer feedback and data.

Collaboration: In a waterfall organization, work is sequential and segmented — with one department’s phase typically unable to advance until the previous one is completed. In an agile organization, teams collaborate on a plan and work cross-functionally and concurrently.

Flexibility: Because of how work is planned and funded, waterfall road-maps have limited flexibility. Agile road-maps accommodate extensive flexibility. This can create its own set of challenges because teams need to be careful that unlimited flexibility does not lead to unnecessary pivots in development and resources.

In this post focus was on how an agile road-map differs from a waterfall road-map, next time we will discuss steps to create an Agile Product Road-map.

What do you think? Let me know your inputs & suggestions.

Courtesy: Several online blogs, you tube videos, tutorials & other resources