2015-12-15 27 views
7

我有一张没有primary key的表格。我真的不想将这个约束应用到这张表上。如何使用SQLAlchemy定义没有主键的表?

SQLAlchemy中,我通过定义的表类:

class SomeTable(Base): 
    __table__ = Table('SomeTable', meta, autoload=True, autoload_with=engine) 

当我试图查询这个表,我得到:

ArgumentError: Mapper Mapper|SomeTable|SomeTable could not assemble any primary key columns for mapped table 'SomeTable'. 

如何丢失的约束每个表都必须有一个主键?

回答