Hello all, I just got into using sqlalchemy today and I have a question about accessing data in a one-to-many relationship.
I've got a simplified example below. Basically the system is for a group of us voting on DVDs we want to rent. There are users and films and for each film a user makes a yes / no choice (where ? is undecided). # create tables users_table = Table('users', metadata, Column('id', Integer, primary_key=True), Column('name', String(40)), mysql_engine='InnodB') films_table = Table('films', metadata, Column('fid', Integer, primary_key=True), Column('title', String(128)), mysql_engine='InnodB') choices_table = Table('choices', metadata, Column('fid', Integer, ForeignKey('films.fid'), primary_key=True), Column('id', Integer, ForeignKey('users.id'), primary_key=True), Column('choice', MSEnum("'?'","'Y'","'N'")), mysql_engine='InnodB') # classes here class User(object): ... class Film(object): .... class Choice(object): .... # mappers mapper(User, users_table) mapper(Film, films_table, properties={'choices':relation(Choice)}) mapper(Choice, choices_table) So, if I retrieve a Film object f, f.choices gives me a list of Choice objects. From that Film object, I want to look up (and possibly modify) a users choice. My question is, is there a way to set up this relationship so that I could access a users choice like a dictionary (either with a user id or User object), or do I have to write a method to search the list and return the object -- in which case, would the changes be reflected in the session / database? Thanks in advance, Most impressed so far, Ken Pierce. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---