Skip to content

Instantly share code, notes, and snippets.

@horacioibrahim
Created March 28, 2014 00:03
Show Gist options
  • Save horacioibrahim/9821964 to your computer and use it in GitHub Desktop.
Save horacioibrahim/9821964 to your computer and use it in GitHub Desktop.
This file contains a small code to check if the limit of 40MB of queries is exclusive of Websrv Mongo. The question was raise in http://stackoverflow.com/questions/22646510/
__author__ = 'horacioibrahim'
# This file contains a small code to check if the limit of 40MB returned by
# Websrv Mongo it's really exclusive where called OP_KILL_CURSORS
# All indicates and a little obvious that result to be returned all documents
# via cursor, BUT we have to run.
# The tests are applicable to mongoDB.
#
# Requirements: bottle and pymongo
#
import bottle
import pymongo
@bottle.route('/<db>/<collection>/')
def query(db, collection):
"""
Make a single query in all documents of a collections and return docs and
total_rows
"""
col = conn[db][collection]
try:
qs = col.find()
except:
print "Unexpected error ", sys.exc_info()[0]
docs = []
for doc in qs:
docs.append(doc)
return bottle.template('{total_rows: {{total_rows}}, obj: {{qs}} }',
dict(qs=docs, total_rows=qs.count()))
conn = pymongo.MongoClient()
bottle.debug(True)
bottle.run(host='localhost', port=8083)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment