Re: [cx-oracle-users] looking for a quicker / more elegant way to form objects with attributes out
Brought to you by:
atuining
From: Massa, H. A. <ch...@gh...> - 2011-03-04 10:32:28
|
Amaury, > Isn't the namedtuple solution enough? > it allows both attribute access and number-based index. aaah, thanks for taking the time to remind me again! I was so focussed on the PostgreSQL PL/Python documentation which talks about "must be attributes to an object" that I missed the "if it behaves like an object, it will be fine" ... it works perfectly with named tuple (which also should give a memory benefit) so for the casual googler: pl/python setof <type> returning functions can use named tuples for the data rows in PostgreSQL Thanks again, Harald > > Your use case is even mentioned in the namedtuple documentation: > http://docs.python.org/dev/library/collections.html#collections.namedtuple > (look for the "sqlite" example) > > -- > Amaury Forgeot d'Arc > -- GHUM GmbH Harald Armin Massa Spielberger Straße 49 70435 Stuttgart 0173/9409607 Amtsgericht Stuttgart, HRB 734971 - persuadere. et programmare |