CouchDB: Returning all design documents with Python
2009-08-21 22:35
I just wanted to get all design documents of a CouchDB database with couchdb-python. I couldn’t find any hints how to do it, it took longer to find out than expected. Therefore this blog entry, perhaps I save someone a few minutes of research.
from couchdb.client import Server
couch_server = Server('http://localhost:5984/')
for designdoc in couch_server['yourdatabase']\
.view('_all_docs', startkey='_design', endkey='_design0'):
print 'designdoc: %s' % designdoc
Update: even simpler with slicing:
from couchdb.client import Server
couch_server = Server('http://localhost:5984/')
for designdoc in couch_server['yourdatabase']\
.view('_all_docs')['_design':'_design0']:
print 'designdoc: %s' % designdoc