Cookies help us deliver our services. By using our services, you agree to our use of cookies. More information

FIND Examples

From NoSQLZoo
Revision as of 12:44, 14 July 2015 by 40166222 (talk | contribs) (Created page with "==Introducing the <code>world</code> collection of countries== <p>These examples introduce NoSQL using MonogDB and PyMongo. We will be using the find() command on the collec...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introducing the world collection of countries

These examples introduce NoSQL using MonogDB and PyMongo. We will be using the find() command on the collection world:

This example shows how to find the population of a country by searching it's name then limiting what fields are returned.
  SELECT population 
  FROM world 
  WHERE name = 'France'

Show the population of France

from pymongo import MongoClient              # Import pymongo
client = MongoClient()                       # Use the default client settings ('mongodb://localhost:27017/')
client.progzoo.authenticate('scott','tiger') # Log in as "Scott" with the password "Tiger"
db = client['progzoo']                       # Use the "progzoo" database

print list(db.world.find({"name":"France"},{"population":1, "_id":0}))

console.log("Hello World");