多表和fi的SQLAlchemy/Flask查询

2024-09-27 23:26:12 发布

您现在位置:Python中文网/ 问答频道 /正文

在Python/Flask应用程序中,到目前为止,我使用了一些简单的查询,比如

     SupportedConfig.query.filter_by(tid=int(form.courses.data)).first()

从表中检索特定的。现在我不知道如何转换以下内容 包含多个表作为SQLAlchemy语句的查询。在

^{pr2}$

架构:

    suppportconfig : int,int,int #sid,tid,did
    distro  : int,string  #did,distroname
    topic  : int,string   #tid,topicname

Tags: form应用程序flaskdatastringbysqlalchemyfilter
1条回答
网友
1楼 · 发布于 2024-09-27 23:26:12

似乎我需要更改模型并添加外键值。 http://docs.sqlalchemy.org/en/rel_0_9/orm/relationships.html

然后与

 supported_config1 = SupportedConfig.query.filter_by(did=distrodb.did,tid=topic.tid).join(distrodb).join(topic).all ()

以获取所需的python列表。在

来源:sqlalchemy irc list

相关问题 更多 >

    热门问题