Is there a way to avoid retrieving an object to delete in many-to-many relationship?
assign = Table('manytomany', Base.metadata,
Column('pid', String(...), ForeignKey('parent.pid')),
Column('cid', String(...), ForeignKey('child.cid'))
)
class Parent():
....
childs = relationship("Child", secondary = assign, backref = 'parent')
I know I can do this:
obj = session.query(Table).get(pk_id)
session.delete(obj)
But I would like have only one database access, something like:
session.query(Table).filter_by(id = pk_id).delete()
I got an error because of the many-to-many rel:
'Cannot delete or update a parent row: a foreign key constraint fails...'
Is it possible? Thx a lot