incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Kocoloski <>
Subject Re: help regarding couchdb python view server
Date Mon, 15 Dec 2008 22:47:01 GMT
On Dec 15, 2008, at 4:05 PM, wrote:

> how do we write couchdb map reduce queries in python.
> i have searched extensively but unable to find a good doc
> Please point me to solutions
> i hope this leads to not writing queries in js
> Thanks

Hi, hopefully this helps to get you started ...

Step 1: Install the couchdb-python library.  You can get it using  
"easy_install couchdb" or by installing from the Google Code source (


Step 2: You should now have a "couchpy" script in your Python scripts  
directory (e.g. /usr/local/bin).  That's the Python view server.  Now  
you need to tell CouchDB to use that view server for design documents  
written in Python.  You do this by adding the following to ${PREFIX}/ 

python = /path/to/couchpy

If you like, you can use the runtime configuration ability of CouchDB  
to send this information to the server:

curl -X PUT http://localhost:5984/_config/query_servers/python -d '"/ 

Step 3: Make sure your design doc specifies "language":"python"

Step 4: The syntax for a python view looks like

def mapfun(doc):
     yield doc["somekey"], doc["somevalue"]

def reducefun(keys, values, rereduce):
     return sum(values)

Regards, Adam

View raw message