Using CouchDB with Perl?

January 22nd, 2012

I’ve been working away on a project where I’ll be using CouchDB and Perl, and was searching the ‘net for information on CouchDB CPAN modules.

There were, of course a lot of CouchDB modules that turned up on MetaCPAN, however I couldn’t figure out which one I should bother messing around with.  I was looking for something simple and straight-forward, similar to the module that was posted in full-source format on Apache CouchDB’s “Getting Started with Perl” guide.

I looked at CouchDB::Client, but found the implementation a little scattered – there are no functions documented that explain how to deal with couchdb documents, only for getting info on and creating databases (the tests in ‘t/’ weren’t very helpful here either).  And the functions don’t say anything about document id’s, which would have been nice.

I also looked at AnyEvent::CouchDB, but again there seemed to be too much going on.. too many methods for doing many things that I won’t need to do.

The “Getting Started with Perl” guide talks about a module called Net::CouchDB, a module that is curiously missing from CPAN as far as MetaCPAN and search.cpan.org are concerned – but Jeremy Zawodny wrote up a nice guide called “Hacking with CouchDB” that uses this module, showing it’s clear interfaces with function names like:

  • $cdb->create_db
  • $cdb->put, and
  • $cdb->new

These are of course in contrast to confusing function names like:

  • $cdb->couch(), or
  • $cdb->replicate()

.. that you’d have to deal with in AnyEvent::CouchDB.

Eventually MetaCPAN lead me to “CouchDB::Simple” which sounded a lot more like what I was looking for.  I didn’t get very far with it however, since the install failed.  I e-mailed the author to give him a heads up, since I don’t think it was my environment at fault (perlbrew perl 5.14.2 + cpanm).  I’ll give it another try this week and see if I can get through that hurdle.

 Update (2012-01-25):  Gave AnyEvent::CouchDB a try, things didn’t go as smoothly as I was hoping.  I can attribute some of this struggle to my lack of familiarity with CouchDB.  Also gave DB::CouchDB a try and got a lot further, but ran into a problem with “bad_content_type” error messages when attempting to post a document to the database.  A little reading and I found that this error can easily be triggered by JSON syntax errors.. but isn’t that what the module is supposed to handle?  I’m thinking I may now give this a try with WWW::Curl or some such, since I’m not having too much luck with CouchDB specific modules… but I’m not done yet :)

 

JBL’s Recently Saved Bookmarks

January 22nd, 2012

My weekly digest of sites, blogs, tools and other URLs which I’ve recently bookmarked for personal reference.

[Quote] Alan Watts on the difference between where we are, and where we are going..

January 22nd, 2012

“… To most of us living today, all these fantasies of the future seem most objectionable: the loss of privacy and freedom, the restriction of travel, and the progressive conversion of flesh and blood, wood and stone, fruit and fish, sight and sound, into plastic, synthetic, and electronic reproductions. Increasingly, the artist and musician puts himself out of business through making ever more faithful and inexpensive reproductions of his original works. Is reproduction in this sense to replace biological reproduction, through cellular fission or sexual union? In short, is the next step in evolution to be the transformation of man into nothing more than electronic patterns?”

” All these eventualities may seem so remote as to be unworthy of concern. Yet in so many ways they are already with us, and, as we have seen, the speed of technical and social change accelerates more than we like to admit. The popularity of science-fiction attests to a very widespread fascination with such questions, and so much science-fiction is in fact a commentary on the present, since one of the best ways of understanding what goes on today is to extend it into tomorrow. What is the difference between what is happening, on the one hand, and the direction of its motion, on the other? If I am flying from London to New York, I am moving westwards even before leaving the British Coast.”

- From: The Book.. On the Taboo Against Knowing Who You Are, by Alan W. Watts,  First Collier Books Edition 1967

JBL’s Recently Saved Bookmarks

January 15th, 2012

My weekly digest of sites, blogs, tools and other URLs which I’ve recently bookmarked for personal reference.

JBL’s Recently Saved Bookmarks

January 8th, 2012

My weekly digest of sites, blogs, tools and other URLs which I’ve recently bookmarked for personal reference.

JBL’s Recently Saved Bookmarks

December 27th, 2011

My weekly digest of sites, blogs, tools and other URLs which I’ve recently bookmarked for personal reference.