gpt4 book ai didi

SQLAlchemy错误- "Please configure one or more attributes for these same-named columns explicitly."

转载 作者:行者123 更新时间:2023-12-04 04:42:04 26 4
gpt4 key购买 nike

我是sqlalchemy的新手。试图使查询正常工作,并且联接出现问题。

我有两个表,每个表都有一个名为“Id”的列,我需要在该表上进行联接。我的代码如下所示:

table1 = server.tab1
table2 = server.tab2
joined = server.join(table1,table2, table1.Id == table2.Id)
where = table1.createDate > start
results = joined.filter(where).all()

这将导致以下错误消息:

Implicitly combining column table1.Id with column table2.Id under attribute 'Id'. Please configure one or more attributes for these same-named columns explicitly.



问题是,如何配置这些属性?

TIA!

最佳答案

用sql汤

joined = server.session.query(table1).join((table2,table1.id == table2.id))
where = table1.createDate > start
results = joined.filter(where).all()

关于SQLAlchemy错误- "Please configure one or more attributes for these same-named columns explicitly.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7797403/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com