Multiple CouchDB Document fetch with couchdb-python

前端 未结 3 1189
广开言路
广开言路 2020-12-31 10:16

How to fetch multiple documents from CouchDB, in particular with couchdb-python?

3条回答
  •  萌比男神i
    2020-12-31 10:47

    import couchdb
    import simplejson as json
    
    resource = couchdb.client.Resource(None, 'http://localhost:5984/dbname/_all_docs')
    params = {"include_docs":True}
    content = json.dumps({"keys":[idstring1, idstring2, ...]})
    headers = {"Content-Type":"application/json"}
    resource.post(headers=headers, content=content, **params)
    resource.post(headers=headers, content=content, **params)[1]['rows']
    

提交回复
热议问题