18

I'm starting to experiment with CouchDB because it looks like the perfect solution for certain problems we have. Given that all work will be on a brand new project with no legacy dependencies, which client library would you suggest that I use, and why?

This would be easier if there was any overlap on the OSes we use. FreeBSD only has py-simplecouchdb already available in its ports collection, but that library's project website says to use CouchDBKit instead. Neither of those come with Ubuntu, which only ships with CouchDB. Since those two OSes don't have an libraries in common, I'll probably be installing something from source (and hopefully submitting packages to the Ubuntu and FreeBSD folks if I have time).

For those interested, I'd like to use CouchDB as a convenient intermediate storage place for data passed between various services - think of a message bus system but with less formality. For example, we have daemons that download and parse web pages, then send interesting bits to other daemons for further processing. A lot of those objects are ill-defined until runtime ("here's some HTML, plus a set of metadata, and some actions to run on it"). Rather than serialize it to an ad-hoc local network protocol or stick it in PostgreSQL, I'd much rather use something designed for the purpose. We're currently using NetWorkSpaces in this role, but it doesn't have nearly the breadth of support or the user community of CouchDB.

craigb
  • 16,827
  • 7
  • 51
  • 62
Kirk Strauser
  • 30,189
  • 5
  • 49
  • 65

6 Answers6

5

I have been using couchdb-python with quite a lot of success and as far as I know the guys of desktopcouch use it in ubuntu. The prerequisites are very basic and you should have not problems:

  • httplib2
  • simplejson or cjson
  • Python
  • CouchDB 0.9.x (earlier or later versions are unlikely to work as the interface is still changing)

For me some of the advantages are:

  • Pythonic interface. You can work with the database like if it was a dict.
  • Interface for design documents.
  • a CouchDB view server that allows writing view functions in Python

It also provides a couple of command-line tools:

  • couchdb-dump: Writes a snapshot of a CouchDB database
  • couchdb-load: Reads a MIME multipart file as generated by couchdb-dump and loads all the documents, attachments, and design documents into a CouchDB database.
  • couchdb-replicate: Can be used as an update-notification script to trigger replication between databases when data is changed.
mandel
  • 2,921
  • 3
  • 23
  • 27
2

If you're still considering CouchDB then I'll recommend Couchdbkit (http://www.couchdbkit.org). It's simple enough to quickly get a hang on and runs fine on my machine running Karmic Koala. Prior to that I've tried couchdb-python but some bugs (maybe ironed out by now) with httplib was giving me some errors (duplicate documents..etc) but Couchdbkit got me up and going so far without any problems.

Kenny Shen
  • 4,773
  • 3
  • 21
  • 18
1

spycouch

Simple Python API for CouchDB

Python library for easily manage CouchDB.

Compared to ordinarily available libraries on web, works with the latest version CouchDB - 1.2.1

Functionality

Create a new database on the server

Deleting a database from the server

Listing databases on the server

Database information

Database compression

Create map view

Map view

Listing documents in DB

Get document from DB

Save document to DB

Delete document from DB

Editing of a document

spycouch on >> https://github.com/cernyjan/repository

Community
  • 1
  • 1
cernyjan
  • 36
  • 2
0

Considering the task you are trying to solve (distributed task processing) you should consider using one of the many tools designed for message passing rather than using a database. See for instance this SO question on running multiple tasks over many machines.

If you really want a simple casual message passing system, I recommend you shift your focus to MorbidQ. As you get more serious, use RabbitMQ or ActiveMQ. This way you reduce the latency in your system and avoid having many clients polling a database (and thus hammering that computer).

I've found that avoiding databases is a good idea (That's my blog) - and I have a end-to-end live data system running using MorbidQ here

Community
  • 1
  • 1
Tom Leys
  • 18,473
  • 7
  • 40
  • 62
  • I see the point you're making, but for the sake of the question, assume I've done due diligence and that it's an appropriate answer for our needs. As I mentioned, it's replacing NetWorkSpaces which is significantly less featureful than any of the options you or I have listed. – Kirk Strauser Oct 20 '09 at 21:53
  • Fair enough - I personally went a long way down the path of using databases to essentially do message passing before I realised that there were much better options outside of databases. – Tom Leys Oct 21 '09 at 01:24
0

I have written a couchdb client library built on python-requests (which is in most distributions). We use this library in production.

https://github.com/adamlofts/couchdb-requests

Robust CouchDB Python interface using python-requests.

Goals:

  • Only one way to do something
  • Fast and stable (connection pooled)
  • Explicit is better than implicit. Buffer sizes, connection pool size.
  • Specify query parameters, no **params in query functions
adam.lofts
  • 1,142
  • 9
  • 10
0

After skimming through the docs of many couchdb python libraries, my choice went to pycouchdb.

All I needed to know was very quick to grasp from the doc: https://py-couchdb.readthedocs.org/en/latest/ and it works like a charm.

Also, it works well with Python 3.

John Smith Optional
  • 22,259
  • 12
  • 43
  • 61