我有两个代表表A和B的类,如下所示
from sqlalchemy.ext.declarative import declarative_base
Class A(Base):
__tablename__ = 'a'
id = Column("user_id", Integer, primary_key=True)
name = Column("user_name", String)
products = relationship("B", back_populates = "users")
Class B(Base):
__tablename__ = 'b'
id = Column("prod_id", Integer, primary_key=True)
name = Column("user_name", String)
users = realtionship("A", back_populates = "products")
我想使用属性产品/用户访问购买产品的所有用户,反之亦然。任何想法如何在不使用会话的情况下完成?