Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Using PostgreSQL array to store many-to-many relationship using sqlalchemy

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Using #PostgreSQL #array #store #relationship #sqlalchemy
ADD COMMENT
Topic
Name
2+5 =