error1062 ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry ’1′ for

设置主键字段为自动递增时报错

ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry ’1′ for key ‘PRIMARY’

需要把数据中已存在主键值为0的记录,改成不为0且不重复的任意数字。


另外flask-sqlachemy的查询语句

eg:

exist = User.query.get(user_name)

get()里写主键字段名,所以想得到相应查询只需在class定义时制定该字段为主键即可

class User(db.Model):
    user_id = db.Column(db.Integer)
    user_name = db.Column(db.String,primary_key=True)



你可能感兴趣的:(error1062 ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry ’1′ for)