MongoDB Simple Example

Following code demonstrates how to:

  • Use the PyMongo library to connect to a Mongo database
  • Insert documents into a collection
  • Display all of the documents from the collection

 

from pymongo import MongoClient

connection= MongoClient('localhost',27017)
 
# connect to the school database and the student collection
db = connection.school.student
 
# create a dictionary to hold student documents
 
# create dictionary
student_record = {}
 
# set flag variable
flag = True
 
# loop for data input
while (flag):
   # ask for input
   student_name=raw_input("Enter student name: ")
   student_grade=raw_input("Enter student grade: ")
   # place values in dictionary
   student_record = {'name':student_name,'grade':student_grade}
   # insert the record
   db.insert(student_record)
   # should we continue?
   flag = input('Enter another record? ')
   if (flag[0].upper() == 'N'):
      flag = False
 
# find all documents
results = db.find()
 
print()
print('+-+-+-+-+-+-+-+-+-+-+-+-+-+-')
 
# display documents from collection
for record in results:
# print out the document
print(record['name'] + ',',record['grade'])
 
print()
 
# close the connection to MongoDB
connection.close()

Insert, Read, Update, Delete in MongoDB using PyMongo

Recently, I had the opportunity of working on Python web application with MongoDB as back end. In this PyMongo tutorial, I’ll brief about MongoDB Insert, Read, Update, Delete Using Python.

 

First of all a short intro of MongoDB and PyMongo :

  • MongoDB :MongoDB is an open-source document database and leading NoSQL database. MongoDB is written in C++.
  • PyMongo :PyMongo is a Python distribution containing tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.

Now, let’s make use of PyMongo to interact with MongoDb.Import the MongoClient from PyMongo.

from pymongo import MongoClient

Now,Create a client connection to the MongoDb instance running on the local machine

client = MongoClient('localhost:27017')
db = client.EmployeeDb   #EmployeeDb is database name

Now that we have the database connection, let’s use the mongo db API to insert document to the database collection using the following command:

Insert document to the database

 employeeId = raw_input('Enter Employee id :')
  employeeName= raw_input('\nEnter name to add\n')
db.Employees.insert_one(
        {
        "id": employeeId,
        "name":employeeName,
   
        })

Read Document From MongoDb

 empCol = db.Employees.find()
    print '\n All data from EmployeeDb Database \n'
    for emp in empCol:
        print emp

Update Document From MongoDb


 criteria = raw_input('\nEnter id to update\n')
    name = raw_input('\nEnter name to update\n')
   

    db.Employees.update_one(
        {"id": criteria},
        {
        "$set": {
            "name":name
           
        }
        }
    )
    print "\nRecords updated successfully\n"    

Delete Document From MongoDb

 criteria = raw_input('\nEnter employee id to delete\n')
 db.Employees.delete_many({"id":criteria})
 print '\nDeletion successful\n' 

why seo is important

why seo is important

Today we are going to learn why seo is important and why we need seo.I have already written article on Seo best practices 2016 and Best seo plugins for wordpress ,you can check them out.

So first of all we are going to know what is Seo.

What is Seo (Search Engine Optimisation )?

In short Seo means making your website/blog Search engine friendly.

Wikipedia’s Defination of Seo

Search engine optimization (SEO) is the process of affecting the visibility of a website or a web page in a web search engine’s unpaid results—often referred to as “natural”, “organic”, or “earned” results. In general, the earlier (or higher ranked on the search results page), and more frequently a site appears in the search results list, the more visitors it will receive from the search engine’s users, and these visitors can be converted into customers.

Now back to our topic why seo is important?

1. SEO brings your Business traffic.
2. SEO gives you unmatched insight into your customers.
3. SEO provides higher relevance and credibility for your business.
4. SEO has one of the best ROI’s (Return On Investment) in advertising.
5. SEO is the number one source of leads.
6. SEO is the most  profitable forms of marketing.
7. SEO is good for business visibility ,branding and digital presence.

 

Best seo plugins for wordpress

Best seo plugins for wordpress

I have previously shared Best Seo practices 2016. For today’s post, I have compiled a list of recommended Best Seo plugins for WordPress. All these SEO plugins helps you too boost your websiste Seo, so I would suggest choosing and using the ones that best suit your needs.

So here are the some Best seo plugins for wordpress:

1. WordPress SEO by Yoast(Top one of the best seo plugins for wordpress)

wordpress-seo-by-yoast

Yoast SEO (formerly known as WordPress SEO by Yoast) is the most complete WordPress SEO plugin that exists today for WordPress.org users. It incorporates everything from a snippet editor and real time page analysis functionality that helps you optimize your pages content, images titles, meta descriptions and more to XML sitemaps, and loads of optimization options in between.

Yoast SEO features:

  • Focus keyword and content analysis
  • Post titles and meta descriptions
  • Robots meta configuration
  • Readability check
  • Canonical
  • Breadcrumbs
  • Primary category
  • Permalink cleanup
  • XML sitemaps
  • RSS enhancements
  • Edit your robots.txt and .htaccess

2. All in One SEO Pack

all-in-one-seo-pack
If you’re looking for a WordPress SEO plugin, then you will likely come across All in One SEO Pack because it is one of the most popular WordPress plugins ever created (over 27 million downloads).

All in One SEO Pack features:

  • XML Sitemap support – submit your sitemap to Google and Bing and improve your SEO
  • Google Analytics support
  • Support for SEO on Custom Post Types
  • Advanced Canonical URLs
  • Automatically notifies search engines like Google and Bing about changes to your site
  • Built-in API so other plugins/themes can access and extend functionality
  • ONLY free plugin to provide SEO Integration for e-Commerce sites, including WooCommerce
  • Nonce Security built into All in One SEO Pack
  • Support for CMS-style WordPress installations
  • Automatically optimizes your titles for Google and other search engines
  • Generates META tags automatically
  • Avoids the typical duplicate content found on WordPress blogs
  • For beginners, you don’t even have to look at the options, it works out-of-the-box. Just install.
  • For advanced users, you can fine-tune everything to optimize your SEO
  • You can override any title and set any META description and any META keywords you want.
  • Compatibility with many other plugins
  • Translated into 57 languages
  • PHP 7 100% Compatible

3. Squirrly SEO

squirrly-seo

SEO Plugin By Squirrly is for the NON-SEO experts. Get Excellent SEO with Better Content, Ranking and Analytics.

You’ll get to improve your rankings, while providing your readers with great content. See Your SEO Stats, get a weekly SEO Audit and find the best keywords.

Squirrly SEO features:

  • Squirrly Snippet Tool
  • Squirrly Keyword Research
  • Squirrly Live Assistant
  • Squirrly Performance Analytics
  • Squirrly First Page Optimization
  • Squirrly Open Graph and Twitter Card
  • Squirrly Check for SEO errors
  • Squirrly Sitemap XML
  • Squirrly Favicon.ico
  • Squirrly Json-LD Structured Data
  • Squirrly Tracking Tools
  • Squirrly Settings for Posts and Pages
  • Squirrly Google Rank Option
  • Squirrly Robots.txt
  • Measure Your Success Option from Squirrly
  • Squirrly Site Audit
  • add multiple tags-keywords
  • Change the Post Permalink in WordPress

4. Broken Link Checker

broken-link-checker

This plugin will check your posts, comments and other content for broken links and missing images, and notify you if any are found.

Broken Link Checker features:

  • Monitors links in your posts, pages, comments, the blogroll, and custom fields (optional).
  • Detects links that don’t work, missing images and redirects.
  • Notifies you either via the Dashboard or by email.
  • Makes broken links display differently in posts (optional).
  • Prevents search engines from following broken links (optional).
  • You can search and filter links by URL, anchor text and so on.
  • Links can be edited directly from the plugin’s page, without manually updating each post.
  • Highly configurable.

5. Rel NoFollow Checkbox

rel-nofollow-checkbox

This plugin  adds a checkbox in the insert/edit link popup for including rel=”nofollow”.

If you have no idea about the added link is good or bad from SEO sake then simply add a rel nofollow attribute for that link. Otherwise  when you linked an external URL, you’re passing link juice and authority from your site to the linked URL. Ignoring this point of view may cause you losing ranking.

6. SEO friendly Images

SEO friendly Images

SEO Friendly Images automatically adds alt and title attributes to all your images improving traffic from search engines.

SEO Friendly Images is a WordPress SEO plugin which automatically updates all images with proper ALT and TITLE attributes for SEO purposes. If your images do not have ALT and TITLE already set, SEO Friendly Images will add them according the options you set. Additionally this makes the post W3C/xHTML valid as well.

ALT attribute is important part of search engine optimization. It describes your images to search engine and when a user searches for a certain image this is a key determining factor for a match.

TITLE attribute play lesser role but is important for visitors as this text will automatically appear in the tooltip when mouse is over the image.

7. SEO Smart Link WordPress plugin

SEO Smart Links provides automatic SEO benefits for your site in addition to custom keyword lists, nofollow and much more.

SEO Smart Links can automatically link keywords and phrases in your posts and comments with corresponding posts, pages, categories and tags on your blog.

Further SEO Smart links allows you to set up your own keywords and set of matching URLs. Finally SEO Smart links allows you to set nofollow attribute and open links in new window.

It is a perfect solution to get your blog posts interlinked or add affiliate links to other sites.

8. W3 Total Cache

w3-total-cache

W3 Total Cache: Search Engine (SEO) & Performance Optimization (WPO) via caching. Integrated caching: CDN, Minify, Page, Object, Fragment, Database support.

W3 Total Cache improves the user experience of your site by increasing website performance, reducing download times via features like content delivery network (CDN) integration.

The only WordPress Performance Optimization (WPO) framework; designed to improve user experience and Search Engine Optimization (SEO). Recommended by countless web hosts.

 

9.WP Performance Score Booster

wp-performance-score-booster%0a

This plugin speed-up page load times and improve website scores in services like PageSpeed, YSlow, Pingdom and GTmetrix.

WP Performance Score Booster features:

  • Remove any query strings from static resources like CSS & JS files
  • Enable GZIP compression (compress text, html, javascript, css, xml and so on)
  • Add Vary: Accept-Encoding header, and
  • Set expires caching (leverage browser caching).

10.NextScripts: Social Networks Auto-Poster

NextScripts: Social Networks Auto-Poster

This plugin automatically publishes posts from your blog to your Social Network accounts such as Facebook, Twitter, Google+(Google Plus), Blogger, Tumblr, Flickr, LiveJournal, Flipboard, Instagram, Telegram, DreamWidth, Delicious, Diigo, Instapaper, Stumbleupon, LinkedIn, Pinterest, Plurk, VKontakte(VK.com), YouTube, App.net, Scoop.It, WordPress, XING etc.

The whole process is completely automated. Just write a new post and either entire post or it’s nicely formatted announcement with backlink will be published to all your configured social networks. You can reach the most audience and tell all your friends, readers and followers about your new post. Plugin works with profiles, business pages, community pages, groups, etc. Messages are 100% customizable and adopted for each network requirements.

 

Hope the above listed plugins helps you to boost your site traffic.I have tried to include the  best seo plugins for wordpress.

If you liked this post, then please share or comment  :).

Seo best practices 2016

Seo best practices 2016

Seo best practices 2016 guide which can boost the traffic of your site/blog.

The top Seo best practices 2016 are as follow:

Tip #1: Find the Best Keywords(Do keyword research)
Tip #2: Discover What Your Competitors are Doing
Tip #3:The text must contains minimum 133 words.
Tip #4: Optimize Your Url, Title and Meta Tags (Must contain your focus keyword)
Tip #5: Optimizing Your Headings and Subheadings.
Tip #6: Use Title (on anchor tag) and ALT Attributes (on images)
Tip #7:  Redirecting Duplicate Content
Tip #8: Optimizing Your Static Site Map
Tip #9: Share you content on social media.
Tip #10: Do guest blog posting on quality blogs.
Tip #11:The meta description should contains the focus keyword.
Tip #12:The Main image of you page/post should contain alt attributes with the focus keyword.

The Most Handy tools,that you must check out are :

1.Google Adwords
2.Google Adsense
3.Google Analytics
4.Google Webmasters
For more detais regarding the seo best practices you can follow the google official   Do you need an SEO? guidelines or check the Webmaster Guidelines

Here are some rules I follow  :

  • update site regularly
  • get good back links over time
  • use Google Keyword tool and Google trends to see what content is most relevant
  • make your site accessible
  • make your site light weight and use less http requests
  • link to great websites
  • use more content then HTML
  • use friendly URLs
  • use a domain that is up in years
  • link to page within your own site
  • provide a robots.txt and sitemap to Google Web Master tools
  • post quality over quantity
  • optimize your website for users not just search (kinda odd but true)
  • use web standards

Below are more detailed tips for creating a Google-friendly site.

Steps to a Google-friendly site:

  1. Give visitors the information they’re looking for
  2. Make sure that other sites link to yours
  3. Make your site easily accessible
  4. Make pages primarily for users, not for search engines.
  5. Don’t deceive your users.
  6. Think about what makes your website unique, valuable, or engaging.

You can check  my another post on Best seo plugins for wordpress ,which can help you to improve you Seo on wordpress.