Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Python client library should I use for CouchdB? [closed]

Tags:

python

couchdb

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.

like image 585
Kirk Strauser Avatar asked Oct 20 '09 18:10

Kirk Strauser


People also ask

What are views in CouchDB?

Basically views are JavaScript codes which will be put in a document inside the database that they operate on. This special document is called Design document in CouchDB. Each Design document can implement multiple view. Please consult Official CouchDB Design Documents to learn more about how to write view.


2 Answers

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.
like image 117
mandel Avatar answered Oct 19 '22 04:10

mandel


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.

like image 2
Kenny Shen Avatar answered Oct 19 '22 05:10

Kenny Shen