如何使用Python在Couchdb中显示所有文档 [英] How to display all documents in Couchdb using Python

查看:92
本文介绍了如何使用Python在Couchdb中显示所有文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用Python.我在Couchdb中有一个名为Student的数据库.我在其中具有[英语,数学,科学,总数,百分比]等属性.我想使用python显示我的学生数据库中的所有文档.我无法访问所有文件.我尝试了以下代码,但没有成功

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'])

推荐答案

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

这篇关于如何使用Python在Couchdb中显示所有文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆