title: How to write queries in python script
body: <p><strong>Data :</strong></p>
  
  <pre><code>{
    "Fruit": "Pomegranate",
    "District": "Nasik",
    "Taluka": "Nasik",
    "Revenue circle": "Nasik",
    "Sum Insured": 28000,
    "Area": 1200,
    "Farmer": 183
  }
  
  {
    "Fruit": "Pomegranate",
    "District": "Jalna",
    "Taluka": "Jalna",
    "Revenue circle": "Jalna",
    "Sum Insured": 28000,
    "Area": 120,
    "Farmer": 13
  }
  
  {
    "Fruit": "Guava",
    "District": "Pune",
    "Taluka": "Haveli",
    "Revenue circle": "Uralikanchan",
    "Sum Insured": 50000,
    "Area": 10,
    "Farmer": 100
  }
  
  {
    "Fruit": "Guava",
    "District": "Nasik",
    "Taluka": "Girnare",
    "Revenue circle": "Girnare",
    "Sum Insured": 50000,
    "Area": 75,
    "Farmer": 90
  }
  
  {
    "Fruit": "Banana",
    "District": "Nanded",
    "Taluka": "Nandurbar",
    "Revenue circle": "NandedBK",
    "Sum Insured": 5000,
    "Area": 2260,
    "Farmer": 342
  }
  
  {
    "Fruit": "Banana",
    "District": "Jalgaon",
    "Taluka": "Bhadgaon",
    "Revenue circle": "Bhadgaon",
    "Sum Insured": 5000,
    "Area": 220,
    "Farmer": 265
  }
  </code></pre>
  
  <p>I want to write queries in a single python script for all types of combinations in this data which gives me exact output what we want.</p>
  
  <p><strong>For example:</strong><br>
  Suppose we want output only for fruit=Banana in Jalgaon district only, so that gives me exact output. </p>
  
  <p>Suppose we want output in which district number of farmers are more than 100 , then that gives exact output.</p>
  
  <p>Suppose we want output only for district=Pune, then that query gives exact output.likewise.</p>
  
  <p>Any hints? How do I write queries to solve this?</p>
  
  <p><strong>Code I tried:</strong> </p>
  
  <pre><code>import pymongo 
  connection = pymongo.MongoClient("mongodb://localhost") 
  db=connection.book 
  record1 = db.book_collection 
  cursor = record1.find({"Fruit":"Banana"},{"Fruit":True, "_id":False, "Farmer":True}) 
  for doc in cursor: 
      print doc # but there I need one python file for one query
  </code></pre>