Re: Different responses to description request between Mac and Linux - Mailing list psycopg

From Daniele Varrazzo
Subject Re: Different responses to description request between Mac and Linux
Date
Msg-id AANLkTimb-dsNaaxqyZ05etj4301060YYx4KV4LJbsjT+@mail.gmail.com
Whole thread Raw
In response to Different responses to description request between Mac and Linux  (Jerry Schneider <jerry57@gmail.com>)
Responses Re: Different responses to description request between Mac and Linux  (Jerry Schneider <jerry57@gmail.com>)
List psycopg
On Tue, Mar 22, 2011 at 12:51 AM, Jerry Schneider <jerry57@gmail.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

psycopg by date:

Previous
From: Jerry Schneider
Date:
Subject: Different responses to description request between Mac and Linux
Next
From: Jerry Schneider
Date:
Subject: Re: Different responses to description request between Mac and Linux