On Sep 23, 2010, at 10:21 AM, Chris Withers wrote:
> >>> from sqlalchemy import *
> >>> engine = create_engine('sqlite://')
> >>> metadata = MetaData()
> >>> sequences = Table(
> ... 'sequences',metadata,
> ... Column('name',String(20),primary_key=True),
> ... Column('current',Integer(),default=0),
> ... )
> >>> sequences.create()
> >>> repr(engine.scalar(select([sequences.c.current],
> >>> sequences.c.name=='foo')))
> 'None'
> >>> 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.
>
> Also odd:
>
> >>> engine.execute(select([sequences.c.current],
> >>> sequences.c.name=='foo')).rowcount
> -1
rowcount
This read-only attribute specifies the number of rows that
the last .execute*() produced (for DQL statements like
'select') or affected (for DML statements like 'update' or
'insert').
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).
--
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.