Re: Array with a lower bound>1, PostgreSQL 8.3.6

Clodoaldo Pinto Neto <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
2009/2/24 Tim Roberts <[email protected]>:
> Thomas Jacob wrote:
>> On Tue, 2009-02-24 at 16:36 +0100, Karsten Hilbert wrote:
>>
>>> Given arbitrary labels we don't speak about mapping
>>> PostgreSQL arrays to Python lists-of-lists anymore, I would
>>> therefore suggest mapping non-"natural" arrays to ordered
>>> (?) dicts-of-dicts with integer keys.
>>>
>>
>> That would probably be easiest and most memory efficient, but
>> I think it would also be bit awkward to have different to get different
>> types depending on the value of the column, and it would probably
>> break old code.
>>
>> Would it be possible to have a configurable type adaptor
>> (don't really what those are yet), so that people could choose
>> which behavior they want? Lists or dicts of dicts?
>
> Well, if you will allow me to throw a spanner into the works, I would
> point out that arrays are a rarely used feature to begin with.  They are
> not standard SQL; they are strictly a Postgres extension, and kind of a
> hacky one at that.

Yes they look and feel hacky but I have used them a couple of times
before. Now that they can contain nulls and composite types they are a
bit better. Very far from python lists but usable.

> If you have found the ideal application for Postgres arrays

I have. I have just built a function that returns multiple result sets
as arrays. It seems like the best solution for the case where the
result sets are not that big. I would prefer if pgsql functions
supported returning multiple result sets but while they don't the
array solution is good enough although a bit too much coding.

Regards, Clodoaldo

> , then I have
> no doubt that Federico would welcome your contribution of a working
> adapter with open arms and a hearty pat on the back, with whatever
> semantics are sensible for you, but I'm not sure you'll get many others
> fired up about helping.
>
> --
> Tim Roberts, [email protected]
> Providenza & Boekelheide, Inc.
>
> _______________________________________________
> Psycopg mailing list
> [email protected]
> http://lists.initd.org/mailman/listinfo/psycopg
>
_______________________________________________
Psycopg mailing list
[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.