On 9/20/15 8:05 AM, [email protected] wrote:
Instances of 'A' can have many references to instances of 'B'.
I want to find all 'B' instances that are not referenced by an 'A'.
I am not sure if this is possible with SQLAlchemy-Query. And I am not
sure if the backref() part in the code is needed for that.
What do you think?
a_b_relation= sa.Table('a_b_relation', _Base.metadata,
sa.Column('a_oid', sa.Integer, sa.ForeignKey('A.oid')),
sa.Column('b_oid', sa.Integer, sa.ForeignKey('B.oid'))
)
class A(_Base):
__tablename__ = 'A'
_oid = sa.Column('oid', sa.Integer, primary_key=True)
_bbb = sao.relationship('B', secondary=a_b_relation, backref='aaa')
class B(_Base):
__tablename__ = 'B'
_oid = sa.Column('oid', sa.Integer, primary_key=True)
k
this will get you that without the "aaa" backref:
print s.query(B).filter(~exists().where(A._bbb)).all()
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.