On 23/09/2010 15:29, Michael Bayer wrote:
repr(engine.execute(select([sequences.c.current],
sequences.c.name=='foo')).scalar())
'None'
Why do I get None instead of an exception raised?
'None' is a scalar....you're thinking of 'query.one()' perhaps.
...but it has no meaning. My understanding of scalar was that it would
take the row returned and turn that into a single element so you don't
have to do:
tuple(engine.execute(...)[0]).someattribute
I guess I'm off base again, what am I misunderstanding?
The attribute is -1 in case no .execute*() has been
performed on the cursor or the rowcount of the last
operation is cannot be determined by the interface. [7]
I've never seen a DBAPI that implements rowcount for DQL (maybe MySQLdb
does...since they load the whole result anyway).
For successful selects, both sqlite and mysql appear to set this. It
sounds like you're saying this attribute isn't safe to use, though...
what is a "right" way to find the number of rows returned from a query,
independent of the database used?
Chris
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en.