> Anyway, what's wrong with explicitly addressing the first row? That's
> how retrieving a one-row-result works..
You are quite right.
It has always seemed odd to me that in asking the database for a
single value you must parse a tabular response with one row and one
column, but on reflection it of course makes sense given that a single
value is just a special case of any more complex query with numerous
rows and columns, aggregate functions or no.
> If you would feel so inclined, you could of course always add this
> functionality yourself and submit a patch :) if it is nice it will
> probably added to web.py.
I did go back and abstract a little further with this helper function:
def count(table, where=None):
return select(table, what='count(*) AS count', where=where)
[0].count
Which reduces the original call to, for example:
count('foo', where="foo.bar = %d" % bar)
However it's barely more than a macro and thus doesn't seem to merit
submitting as a patch. Thanks for the encouragement though!
Best wishes,
--
Alex Macmillan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---