unable to create autoincrementing primary key with flask-sqlalchemy

前端 未结 6 2149
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 03:47

I want my model\'s primary key to be an autoincrementing integer. Here is how my model looks like

class Region(db.Model):
    __tablename__ = \'regions\'
            


        
6条回答
  •  被撕碎了的回忆
    2020-12-13 04:30

    I think you do not need the autoincrement once you set ,

    id = db.Column(db.Integer , primary_key=True , autoincrement=True)
    

    I think that it should be ,

    id = db.Column(db.Integer , primary_key=True)
    

    it will give you the uniqueness your looking for .

提交回复
热议问题