X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B8E85DBCBD for ; Sun, 20 Nov 2005 00:14:47 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62545-05 for ; Sun, 20 Nov 2005 04:14:45 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from web52902.mail.yahoo.com (web52902.mail.yahoo.com [206.190.49.12]) by svr1.postgresql.org (Postfix) with SMTP id C5CA3DBCA4 for ; Sun, 20 Nov 2005 00:14:44 -0400 (AST) Received: (qmail 29071 invoked by uid 60001); 20 Nov 2005 04:14:40 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=rg9uTKPj5xHBv0kd2ZHULdt4W5uCxX2QA67wKgj7ssuHxFIsKoN7XcSYqhioTHtkJDWIIeK60SM1pVOQ83W1R4Zj8sTqPpjAdk0KQI0qNRbGWYFV7+q0CZaeKY0NVyLDmppAxNxu6ak85YzomyiQaxA0wm7y9eu2Vw99gXPXtlM= ; Message-ID: <20051120041440.29069.qmail@web52902.mail.yahoo.com> Received: from [130.253.161.23] by web52902.mail.yahoo.com via HTTP; Sat, 19 Nov 2005 20:14:40 PST Date: Sat, 19 Nov 2005 20:14:40 -0800 (PST) From: CSN Subject: ruby/postgres - getting assoc array of rows? To: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.696 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479, FROM_HAS_ULINE_NUMS=0.217] X-Spam-Score: 0.696 X-Spam-Level: X-Archive-Number: 200511/51 X-Sequence-Number: 5847 Looking at the docs here: http://ruby.scripting.ca/postgres/reference.html there doesn't appear to be an easy way to get an associative row of rows returns. Looking in Rails PG code, I see this convolution: def select(sql, name = nil) res = execute(sql, name) results = res.result rows = [] if results.length > 0 fields = res.fields results.each do |row| hashed_row = {} row.each_index do |cel_index| column = row[cel_index] if res.type(cel_index) == BYTEA_COLUMN_TYPE_OID column = unescape_bytea(column) end hashed_row[fields[cel_index]] = column end rows << hashed_row end end return rows end Is there a much easier and simpler way? csn __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com