我在谷歌搜索得很好但我似乎无法在我的案例中找到这个错误的答案。
我没有做任何加入,我只是想从这张桌子上得到所有。
所有其他查询工作正常,但这似乎弄乱了这个错误:
InvalidRequestError: Ambiguous column name 'INMPTL_WIW_BATAM_STG.pers_no' in result set! try 'use_labels' option on select statement.模型:
batamStg = sa.Table("INMPTL_WIW_BATAM_STG", meta.metadata, sa.Column("PERS_NO", sa.types.String(),primary_key=True), sa.Column("FIRST_NAME", sa.types.String()), sa.Column("LAST_NAME", sa.types.String()), sa.Column("KNOWN_AS", sa.types.String()), sa.Column("JOB_TITLE", sa.types.String()), sa.Column("MANAGER_NAME", sa.types.String()), sa.Column("MANAGER_ID", sa.types.String()), sa.Column("MANAGER_COST", sa.types.String()), autoload=True, autoload_with=engine)视图:
btm = meta.Session.query(model.BatamStaging).all();此处只有一列名为Pers_no,所有主键都是唯一的。
如果我尝试将LAST_NAME设置为主键,也会出现同样的错误。
其他人遇到过这个问题吗?
Ive had a good search on google but I cant seem to find an answer to this error in my case.
Im not making any joins, Im literally just trying to get all from this table.
All of the other queries work fine, but this seems to be messing up with this error:
InvalidRequestError: Ambiguous column name 'INMPTL_WIW_BATAM_STG.pers_no' in result set! try 'use_labels' option on select statement.Model:
batamStg = sa.Table("INMPTL_WIW_BATAM_STG", meta.metadata, sa.Column("PERS_NO", sa.types.String(),primary_key=True), sa.Column("FIRST_NAME", sa.types.String()), sa.Column("LAST_NAME", sa.types.String()), sa.Column("KNOWN_AS", sa.types.String()), sa.Column("JOB_TITLE", sa.types.String()), sa.Column("MANAGER_NAME", sa.types.String()), sa.Column("MANAGER_ID", sa.types.String()), sa.Column("MANAGER_COST", sa.types.String()), autoload=True, autoload_with=engine)View:
btm = meta.Session.query(model.BatamStaging).all();There is only one column called Pers_no here and all of the primary keys are unique.
The same error also occurs if I try to set LAST_NAME as the primary key.
Has anyone else had this issue?
最满意答案
我的猜想是,当覆盖使用autoload=True反映的列时,列名称的区分大小写 。 要验证,请注释掉所有列定义并保留autoload=True 。 然后做相反的事情。
有关详细信息,请参阅反映数据库对象 - 覆盖 SA文档的反射列 。
My conjecture would be the case-sensitivity of column names when overriding columns which are reflected by using autoload=True. To verify, comment out all column definition and leave autoload=True. Then do the opposite.
See Reflecting Database Objects - Overriding Reflected Columns of SA documentation for more information.
更多推荐
发布评论