Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从SQLAlchemy中的M:N关系获取所有值_Python_Python 3.x_Sqlalchemy_Marshmallow Sqlalchemy - Fatal编程技术网

Python 从SQLAlchemy中的M:N关系获取所有值

Python 从SQLAlchemy中的M:N关系获取所有值,python,python-3.x,sqlalchemy,marshmallow-sqlalchemy,Python,Python 3.x,Sqlalchemy,Marshmallow Sqlalchemy,我将sqlalchemy中的M:N关系定义为: association_table = Table('association_table', base.metadata, Column('content_id', UUID(as_uuid=True), ForeignKey('content.content.content_id'), primary_key=True),

我将sqlalchemy中的M:N关系定义为:

association_table = Table('association_table', base.metadata,
                          Column('content_id', UUID(as_uuid=True),
                                 ForeignKey('content.content.content_id'), primary_key=True),
                          Column('message_id', UUID(as_uuid=True), ForeignKey('messages.webhooks.message_id'), primary_key=True),
                          schema='content'
                          )
class Messsages(base):
    __table_args__ = {"schema": "messages"}
    __tablename__ = 'webhooks'
    id = Column('message_id', UUID(as_uuid=True), primary_key=True)
    parents = relationship(
        "Content",
        secondary=association_table,
        back_populates="children", uselist=False)

class Content(base):
    __tablename__ = "content"
    __table_args__ = {"schema": "content"}
    id = Column("content_id", UUID(as_uuid=True), primary_key=True)
    children = relationship(
        Messsages,
        secondary=association_table,
        uselist=False,
        back_populates="parents")


class ContentRepository:
    def __init__(self, session):

    def get_all(self):
        return self.session.query(Content).all()


for config in ContentRepository(session).get_all():
        ids = config.children.id
我在ids中只得到一个值,表中有多行,但它只返回一个值