Помогите, пожалуйста, как сделать данный запрос в sqlalchemy?
select * from vouchers
where "closed" not in (select orders.status from orders
where orders.voucher_id = vouchers.id);
Примеры моделей в sqlalchemy
class Voucher(Base):
__tablename__ = "vouchers"
id = Column(BigInteger, primary_key=True, autoincrement=True)
orders = relationship ("Order")
class Order (Base):
__tablename__ = "orders"
id = Column (BigInteger, primary_key=True, autoincrement=True)
voucher_id = Column (BigInteger, ForeignKey("vouchers.id")
voucher = relationship (Voucher)