On Oct 30, 2010, at 5:59 PM, James Hartley wrote:
>
>
> The following Python code:
>
> for t in session.query(func.max(Cron.timestamp)).\
> join((Snapshot, Cron.id == Snapshot.cron_id), (Platform,
> Platform.id == Snapshot.platform_id)).\
> filter(Platform.id == platform_id):
> print t
>
> ...or variations such as:
>
> t = session.query(func.max(Cron.timestamp)).\
> join((Snapshot, Cron.id == Snapshot.cron_id), (Platform,
> Platform.id == Snapshot.platform_id)).\
> filter(Platform.id == platform_id).one()
>
> ...all are giving me the following error. I suspect I am missing something
> obvious. Any insight shared would certainly be appreciated.
>
>
> 2010-10-30 14:47:43,783 INFO sqlalchemy.engine.base.Engine.0x...dccL SELECT
> max(cron_events.timestamp) AS max_1
> FROM cron_events JOIN snapshots ON cron_events.id = snapshots.cron_id JOIN
> platforms ON platforms.id = snapshots.platform_id
> WHERE platforms.id = %(id_1)s
> 2010-10-30 14:47:43,790 INFO sqlalchemy.engine.base.Engine.0x...dccL {'id_1':
> (1,)}
the log shows the issue. You intend for plaform_id to be an integer, i.e.
"1". In fact a tuple is being passed, "(1,)". While not pictured here, the
pattern that would produce this is:
platform_id = Session.query(Platform.id).filter(...).first()
some_query.filter(Platform.id==platform_id)
You intend to say:
platform_id = Session.query(Platform.id).filter(...).first()[0]
or:
platform_id= Session.query(Platform.id).filter(...).scalar()
--
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.