Peewee gets confused with manually inserted data (ids and primary keys)

  Kiến thức lập trình

I am working with a friend of mine, we have some peewee application which workes fine on it’s own, but wenn we manually insert data in the database (migrated an old database) peewee gets confused with the ids, peewee starts at 0 with ids again and oh wonder that id already exists and peewee can’t insert models

Does anybody know a way to fix this

example model would look like this

class SomeModel(Model):
  // no id defined here, peewee does that automatically
  username = CharField()
  password = CharFIeld()
  age = IntegerField()

Insert is done like this:

db.connect()
result = some_instance.save()
db_data.close()
return result

this returns None, when id already exists

Thanks for your help!

LEAVE A COMMENT