出错代码:
#生成抽象模型,不会创建模型对应的表,减少重复代码
class BaseModel(db.Model):
__abstract__ = True
id = db.Column(db.Integer, pramary_key=True, autoincrement=True)
name = db.Column(db.String(20), unique=True, nullable=False)
class Role(BaseModel):
__tablename__ = 'role'
id = db.Column(db.Integer, pramary_key=True, autoincrement=True)
name = db.Column(db.String(20), unique=True, nullable=False)
class Qx(BaseModel):
__tablename__ = 'qx'
id = db.Column(db.Integer, pramary_key=True, autoincrement=True)
name = db.Column(db.String(20), unique=True, nullable=False)
报错:sqlalchemy.exc.ArgumentError: Mapper mapped class Role->role could not assemble any primary key columns for mapped table 'role'
原因:primary_key
写成了pramary_key