Opened 9 years ago

Closed 4 years ago

#22 closed enhancement (fixed)

Let pgdb support namedtuples

Reported by: cito Owned by: D'Arcy J.M. Cain
Priority: major Milestone: 5.0
Component: DB API 2 Version: 4.1
Keywords: named tuples Cc:


Python 2.6 comes with namedtuples. We should utilize these in pg and pgdb.

pg could get a new method namedresult(), and pgdb could provide a row factory for namedtuples (similar to sqlite3).

Change History (3)

comment:1 Changed 7 years ago by cito

Implemented for pg in r447.

comment:2 Changed 4 years ago by cito

Summary: Let pg and pgdb support namedtuplesLet pgdb support namedtuples

Renamed the ticket to reflect the current status.

comment:3 Changed 4 years ago by cito

Keywords: named tuples added
Milestone: 4.25.0
Resolution: fixed
Status: newclosed
Version: 4.04.1

Support for named tuples has now been added in r683, tests and docs are also included.

I have made this even the default for version 5.0, since the new major version is a good opportunity to make such changes. We used to return rows as lists in the pgdb module, which was not good anyway because it was not in line with the pg module and other database drivers. Note that named tuples can be accessed the same way as lists, so the backward incompatibily is small and would normally not cause troubles.

Note: See TracTickets for help on using tickets.