title: Not able to iterate mongo object in python
body: <p>I am trying to get the records (books), which are present the in Mongo DB collection "books". I am using pymongo and flask. </p>
  
  <p>Below is my code. In the code, if I remove the query update line (<code>query.update({'author': 'sachin'})</code>), it works fine. </p>
  
  <p>What is the problem while updating the query dict?</p>
  
  <pre><code>from pymongo import connection as pymongo_client
  import urllib
  
  
  def get_books(query, skip_val=0, limit=None):
      conn, client = _connect()
      if limit:
          result = client.books.find(query).skip(skip_val).limit(limit)
      else:
          result = client.books.find(query)
      conn.close()
      return result
  
  
  def _connect():
      user = "root"
      password = "password"
      host = "172.17.1.14"
      port = "27017"
      db_name = "books"
      auth_database = "admin"
      if user and password and auth_database:
          uri = "mongodb://%s:%s@%s:%s/%s" % (
              user, urllib.quote_plus(password), host, port, auth_database)
      else:
          uri = "mongodb://%s:%s" % (host, port)
      conn = pymongo_client.Connection(uri, j=True)
      db = conn[db_name]
      return conn, db
  
  query = {'project_name': 'cricket'}
  
  books = get_books(query)
  
  query.update({'author': 'sachin'})
  
  for book in books:
      print book
  </code></pre>