小编ale*_*ire的帖子

类在 SQLalchemy 中没有名为“x”的映射列

我在 Django 环境中使用 SQLAlchemy (v1.2.11),所以我可以在 Firebird 数据库(由公司的 ERP 使用)和我在 Django 中开发的内部网之间进行一些映射。我使用declarative_base进行映射,因为自省不起作用。

限制之一是 Firebird 本身(版本 1.5),它没有多大帮助,而且我不能接触数据库,只能执行 SELECT 查询。

我想做的一件事是让用户在某些特定情况下创建报告并与 Firebird 数据交互,在我的 Django 项目中创建相关记录。

但是,在一个特定的映射中,我得到

Class <class 'SalesDetail'> does not have a mapped column named 'seller_id'
Run Code Online (Sandbox Code Playgroud)

当查询准备好并使用关系时。让我发疯的是,我还在 ProductSells 类中映射了另外两个关系,它们非常相似并且工作正常。

首先,我的基本映射与我要查询的表 (SalesDetail) 相关:

class Sellers(Base):
    __tablename__ = 'sellers'

    seller_id = Column('seller_id', Integer)
    company_id = Column('company_id', Integer)
    name = Column('name', String)

    __mapper_args__ = {
        'primary_key': [seller_id, company_id],
    }


class Products(Base):
    __tablename__ = 'products'

    product_code = Column('product_code', Integer)
    company_id = Column('company_id', Integer)
    name …
Run Code Online (Sandbox Code Playgroud)

python sqlalchemy

2
推荐指数
1
解决办法
1234
查看次数

标签 统计

python ×1

sqlalchemy ×1