Skip site navigation (1) Skip section navigation (2)

Re: Different responses to description request between Mac and Linux

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: jerry(at)iplantcollaborative(dot)org
Cc: Jerry Schneider <jerry57(at)gmail(dot)com>, psycopg(at)postgresql(dot)org
Subject: Re: Different responses to description request between Mac and Linux
Date: 2011-03-22 02:24:01
Message-ID: AANLkTimb-dsNaaxqyZ05etj4301060YYx4KV4LJbsjT+@mail.gmail.com (view raw or flat)
Thread:
Lists: psycopg
On Tue, Mar 22, 2011 at 12:51 AM, Jerry Schneider <jerry57(at)gmail(dot)com> wrote:
> I am working on extending a library for RobotFramework and added a keyword
> for column description retrieval but noticed that when I run it on Mac OS X
> 10.6 I am getting:
> Column(name='id', type_code=20, display_size=None, internal_size=8,
> precision=None, scale=None, null_ok=None)
> but when I run the exact same test against the exact same database from an
> Ubuntu 10.10 Linux box I am getting:
> ('id', 20, None, 8, None, None, None)
>
> The only difference that I can find is that the Mac box is running psycopg2
> 2.4 installed via (python setup.py install) while the Ubuntu box is running
> psycopg2 2.2.1 installed via package management.  Is it possible that this
> version difference is what is accounting for the response difference?

Yes: from 2.4 cursor.description is provided as namedtuple if
available (http://initd.org/psycopg/docs/cursor.html#cursor.description).

Named tuple are accessible as regular tuple via indexing and hash the
same, see <http://docs.python.org/library/collections.html#collections.namedtuple>
so there should be no backward compatibility problem (but if you have
found any... let's talk about that).

If your concern are doctest (the first thing that comes to mind that
may have been broken by the namedtuple... but that's because doctests
are a broken idea) you can use tuple(x) to transform a namedtuple back
in a regular tuple.

-- Daniele

In response to

Responses

psycopg by date

Next:From: Jerry SchneiderDate: 2011-03-22 03:49:41
Subject: Re: Different responses to description request between Mac and Linux
Previous:From: Jerry SchneiderDate: 2011-03-22 00:51:39
Subject: Different responses to description request between Mac and Linux

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group