Thanks, works great!!!

On Jun 20, 10:06 am, Michael Bayer <[email protected]> wrote:
> On Jun 20, 2011, at 1:02 AM, Carlos Mendoza wrote:
>
>
>
>
>
>
>
>
>
> > Hi, I want to remove an association in many to many relation, but I
> > don't want delete the related objects, just the association.
> > If I have:
>
> > ProjectUser = Table('PROJECT_USER', metadata,
> >    Column('id_user', Integer, ForeignKey('USER.id_user')),
> >    Column('id_project',Integer, ForeignKey('PROJECT.id_project')),
> > )
> > class Project(DeclarativeBase):
>
> >    __tablename__ = 'PROJECT'
>
> >    #{ Columns
>
> >    id_project = Column(Integer, Sequence('id_project_seq'),
> > primary_key=True)
> >    name = Column(Unicode(25), nullable=False)
> >    description = Column(Unicode(200), nullable=False)
>
> >    #{ Relations
> >    users = relation("Users", secondary=ProjectUser,
> > backref=backref('projects',order_by=id_project))
>
> > I append a user with:
> > aProject.users.append(aUser)
>
> > But, if I want to delete this association between aProject and aUser,
> > how I must proceed?
>
> When you use "secondary", the contents of the table marked by "secondary" are 
> managed automatically upon next flush as you append or remove items from the 
> "users" or "projects" collection, using append(), remove() or other 
> collection modifiers.

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

Reply via email to