Hi All,

I have a query previously written with the old "select" approach that
used a join:

        sua = SurveyUserActivity
        all_users = SurveyUser

        user_view = select([all_users.c.id,
                          all_users.c.user_name,
                          all_users.c.user_email]
                          ).alias('user_view')

        recent_users = select([sua.c.user_id, func.max(
                            sua.c.last_updated).label('last_used')],
 
group_by=[sua.c.user_id]).alias('recent_users')

        users = join(user_view, recent_users,
                     user_view.c.id==recent_users.c.user_id <--- Error
here
                     ).select().execute().fetchall()

that I need to rewrite using sessions - we're using z3c.alchemy within
a zope3 application, where the session is just retrieved using:

session = z3c.zalchemy.getSession()

The tables are defined as, e.g.,

class ISurveyUser(ISQLAlchemyObject):

    id = zope.schema.Int(
        title=_(u'User ID'),
        description=_(u"What is the ID of the user?"))
    ...

class SurveyUser(object):
    """User object mapped to user table"""

    zope.interface.implements(interfaces.ISurveyUser)
    ...

When I run the above code, I get an error at the point indicated
above:

  File ".../SQLAlchemy-0.4.2p3-py2.4.egg/sqlalchemy/sql/
expression.py", line 991, in execute
InvalidRequestError: This Compiled object is not bound to any Engine
or Connection.

Whichever way I can get this to work would be great. Thanks in advance
for any help.

Cheers, Andrew.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to