Hi there,
I try to grasp relations ..
I have an m:n association between two tables.
this is what I do:
engine = sa.create_engine('mysql://[EMAIL PROTECTED]/energie_2', echo=True)
Session = sessionmaker(bind=engine)
session = Session()
this is what I have:
tblPersonTable and tblSupplierTable derived from BASE and work fine on
their own
class User(tblPersonTable):
suppliers = relation(
tblSupplierTable,
secondary=tblPersonSupplierTable.__table__,
backref='suppliers')
def getRecordsForUser():
supplier = session.query(tblSupplierTable).filter_by(id=12).one()
user=session.query(User).filter_by(plone_id='johndoe').one()
user.suppliers.append(supplier)
session.update(user)
...
as you can see User has a relation that connects to Supplier via an
association table.
in the above method I get supplier and user as expected.
user.suppliers has one entry as it should have, so the relation works.
user.suppliers.append(supplier) adds a second supplier.
now session.update(user) should write a new entry into the association
table I *think*.
but it does not.
can somebody give me a hint what I should do to make it happen?
robert
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---