-->

How to display all documents in Couchdb using Pyth

2019-07-08 20:59发布

问题:

I have recently started using Python. I have a database called student in Couchdb. I have attributes in it like [english, maths, science, total, percentage]. I want to display all the documents from my student database using python. I cant access all the documents. I tried following code but didnt work

couch = couchdb.Server()
db = couch['student']
rows = db.view('_all_docs', include_docs=True)
for row in rows:
    doc = db.get(row)
    print(doc['english'])

回答1:

import couchdb
couch = couchdb.Server('localhost:5984/')

db = couch['newtweets']
count = 0
for docid in db.view('_all_docs'):
    i = docid['id']
#and you are in each document