couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Hirst <>
Subject Re: [somewhat off-topic] Any good perl modules for consuming CouchDB? Having trouble with Perl's CouchDB::Client
Date Fri, 01 Apr 2011 07:19:47 GMT
On Thu, 2011-03-31 at 18:28 +0100, Luis Miguel Silva wrote:
> Dear all,
> Sorry for yet another email but i was wondering if anybody in the
> community has had good experiences querying views from Perl?
> I'm trying CouchDB::Client perl module but i simply cannot consume a
> view i created...
>         my $db = $c->newDB('mydatabase');
>         print "puff\n";
>         my $view = $db->newDesignDoc('_design/testviewdoc')->retrieve;
>         my $result = try {
>                 $view->queryView('testviewname');
>         } catch {
>                 die "Could not query view";
>         };

I tried you code, after a few tweaks, in my environment against one of
my databases and it works fine.

The entire piece of perl I ran was this:

use CouchDB::Client;
use Try::Tiny;
use strict;
use warnings;
my $c = CouchDB::Client->new( uri => "http://uk-couch:5984");
my $db = $c->newDB('ddb');
print "puff\n";
my $view = $db->newDesignDoc('_design/conflicts')->retrieve;
my $result = try {
} catch {
        die "Could not query view";

Make sure you are using CouchDB::Client version 0.09. I have found older
versions to be a bit buggy. I haven't yet had any issues with version

You might find it useful to add the following lines after the my $c = ..

$c->{ua}->add_handler("request_send",  sub { shift->dump; return });
$c->{ua}->add_handler("response_done", sub { shift->dump; return });

Then you can see the entire requests and responses which could give you
more clues about what is going wrong.

So far I've found CouchDB::Client to be the best module for Perl.
Net::CouchDB seems to have disappeared and AnyEvent::CouchDB didn't work
for me (threw errors in the AnyEvent::HTTP module) and might be a
paradigm you don't want to use.

Sophos Limited, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom.
Company Reg No 2096520. VAT Reg No GB 991 2418 08.

View raw message