Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25326 closed New feature (fixed)

Add an example with namedtuple to "Executing custom SQL directly"

Reported by: Dražen Odobašić Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Namedtuples can be used to provide more convenient access for custom SQL Results. This PR adds an example for namedtuple wrapper function and shows differences between normal (tuple), dict and namedtuple wrapper functions.

Change History (6)

comment:2 by Dražen Odobašić, 9 years ago

Couple of remarks:

  • examples are Python2 as 'id': 54360982L, in Python3 all integers are implemented as long integers and as we are pushing Python3, we should probably change it
  • as cursors are iterable examples could be improved in a way to not use fetchall() but return a generator, and then use list comprehensions to actually show the difference between approaches

comment:3 by Tim Graham, 9 years ago

Has patch: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

Looks reasonable, but docs should assume Python 3. Haven't taken time to understand point 2, but if you want to make those updates as a separate commit, I'll take a look. After you make the updates, please uncheck "Patch needs improvement" on the ticket so it returns to the review queue. Thanks!

comment:4 by Dražen Odobašić, 9 years ago

Patch needs improvement: unset

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 5ab65ca5:

Fixed #25326 -- Added namedtuple example for executing custom SQL.

comment:6 by Tim Graham <timograham@…>, 9 years ago

In 5ed9616:

[1.8.x] Fixed #25326 -- Added namedtuple example for executing custom SQL.

Backport of 5ab65ca5c900557f508f62a260f9ea53d9d93f37 from master

Note: See TracTickets for help on using tickets.
Back to Top