Opened 4 years ago

Closed 6 months ago

#67 closed enhancement (fixed)

Add methods for returning scalar values

Reported by: cito Owned by:
Priority: minor Milestone: 5.1
Component: Classic and DB API Version: 4.1
Keywords: scalar Cc:


Often you have queries that are intended to return only a single row of values, a single column of values, or just a single value.

In these cases, it would be useful to have methods that return the data only as a single sequence (not a sequence of sequences), or a single value.

The DB API 2 already has the fetchone() method that can be used to get a single row. The classic interface does not have such a method. Both do not have a method for returning a single column or single scalar value.

Maybe a fetchscalar() method for the DB API 2 and a getscalar() method for the classic interface would be useful.

See also #48 ("Add methods returning interator of rows to the classic module") in this context.

Change History (2)

comment:1 Changed 6 months ago by cito

Added methods one(), single(), scalarresults() and variants to the query in the classic interface in r980.

comment:2 Changed 6 months ago by cito

Resolution: fixed
Status: newclosed

Decided to not add such a method to the DB-API 2 module since it does not really spare much typing but thwarts the usage of a standardized API.

Note: See TracTickets for help on using tickets.