Quantcast
Channel: Jarrod Roberson: Programming Missives » api
Viewing all articles
Browse latest Browse all 2

Get All Views from All Databases in CouchDB

$
0
0

Here is a little code snippet on how to get a list of all the Views from all the Design Documents from all the Databases in a CouchDB instance with couchdbkit.

#!/usr/bin/env python

from couchdbkit import *

server = Server()
dbs = server.all_dbs()
for dbname in dbs:
    db = server.get_or_create_db(dbname)
    result = db.all_docs(startkey=‘_design’, endkey=‘_design0′)
    for doc in result.all():
       designdoc = db.get(doc['id'])
       if ‘views’ in designdoc:
           for view in designdoc['views']:
              print ‘%s/%s/_view/%s’ % (dbname, designdoc['_id'], view)


Viewing all articles
Browse latest Browse all 2

Trending Articles