models.py
class Gender(db.Model):
__tablename__ = 'gender'
type_choices = (
(1, 'male'),
(2, 'female'),
(3, 'None'),
)
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(64))
types = Column(ChoiceType(type_choices, impl=sa.Integer()))
__table_args__ = {
'mysql_engine': 'Innodb',
'mysql_charset': 'utf8',
}
python3 manage.py db migrate后的文件,这里会报错:
sa.Column('types', sqlalchemy_utils.type.choice.ChoiceType(), nullable=True),
解决方案:
百度搜索关键词:sqlalchemy_utils.types.choice.ChoiceType()
英文好的可以戳下面_0.0_:
https://stackoverflow.com/questions/29330578/error-at-migrating-in-flask-with-sqlalchemy-utils-choicetype
在报错的地方再导一遍sqlalchemy_utils,ChoiceType(args):
sa.Column('types', sqlalchemy_utils.types.choice.ChoiceType(Gender.type_choices), nullable=True),