📜  使用 PostgreSQL 数组存储多对多关系使用 sqlalchemy - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:36.185000             🧑  作者: Mango

代码示例1
class A(Base):
    __tablename__ = "table_a"
    id = Column(Integer, primary_key=True)
    name = Column(String)

class B(Base):
    __tablename__ = "table_b"
    id = Column(Integer, primary_key=True)
    name = Column(String)
    array_a = Column(postgresql.ARRAY(Integer))

    a_ids= relationship('A',primaryjoin='A.id == any_(foreign(B.array_a))',uselist=True)