Disclaimer: I'm no SQLAlchemy guru.

On Fri, Jul 13, 2007 at 01:53:48PM -0000, robertz23 wrote:
>      Hi,  I've been using SQLAlchemy since a month.  I'm having some
> problems with a one-to-many relationship.  I have 2 tables: one for
> users and one for users's emails.  The problem arises when I want to
> put a timestamp in the email table in order to see when a given
> account was created.  Here are the tables, my code, and the error:
> [...]
> user_table = Table('user', metadata, autoload=True)
> email_table = Table('email', metadata, autoload=True)
> class User(object):
>     pass
> class Email(object):
>     pass
> session_context = SessionContext(create_session)
> assign_mapper(session_context, User, user_table,
> properties={'emails':relation(Email)})
> assign_mapper(session_context, Email, email_table)
> 
> obj = User()
> obj.get(1).emails

It looks like you are first creating a new User instance and then
calling .get(1) on it. I'd rather expect this to work:

emails = User.get(1).emails

Or following the query syntax that seems to be upcoming with 0.4:

emails = User.query.get(1).emails

Kindly
 Christoph


--~--~---------~--~----~------------~-------~--~----~
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