[orm-devel] Issue, current CVS
Diedrich Vorberg
orm-devel@mailman.tux4web.de
Sat, 23 Nov 2002 12:03:05 +0100
>Good morning
thanks, just had breakfast :)
>I like being able to test simply for some things -
>
>if p:
> do stuff
>
>is much easier to write but perhaps I should be throwing most of these
>object requests into a try: except: block.
>
>Or I can always wrap ds.select in a function if I need to.
What's wrong with queryOne?
The real problem is, there is no len(result), because there is no way
to tell the length of a result from the cursor. (At least there's no
such function/attribute in the db-sig's description of cursor
objects). I think psql does provide this info, but I'm not sure if
psycopg's cursors contain it. Anyway, this would create a situation
in which queryResult classes must be db specific.
>PS: For fun earlier this evening I changed the result of _fromTuple to be
>None if an empty result was the answer - was surprised but it 'appears' not
>to have broken anything. I have not done any serious testing on this
>however and am certainly not suggesting that you retrofit it.
Don't. fromTuple is supposed to be a constructor. A constructor can't
return None. ok ok in Python in can, but still.
The fetchone() method was ment for results of which you know there's
only one row. The result iterators are for the others. fetchall() is
ment to be used in cases you know the result will fit main memory and
you have to iterate over the result twice.
I'm not particularly happy with this setup: it is not very obvious.
Diedrich
--
_..._ Diedrich Vorberg
.' '.
/ _ _ \ http://www.tux4web.de
| (o)_(o) | info@tux4web.de
\( ) / .---.
//'._.'\ \ / \ Internet Dienstleistungen
// . \ \ \.@-@./ und 'Consulting'.
|| . \ \ /`\_/`\
|\ : / | // _ \\ Linux Rules!
\ `) ' (` /_ | \ )|_
_)``".____,.'"` (_ /`\_`> <_/ \
) )'--'( ( \__/'---'\__/
'---` `---`