I am trying to learn how to use peewee with mysql.
I have an existing database on a mysql server with an existing table. The table is currently empty (I am just testing
If your primary key column name is other than 'id' you should add additional field to that table model class:
class Table(BaseModel):
id_field = PrimaryKeyField()
That will tell your script that your table has primary keys stored in the column named 'id_field' and that column is INT type with Auto Increment enabled. Here is the documentation describing field types in peewee.
If you want more control on your primary key field, as already pointed by Francis Avila, you should use primary_key=True argument when creating field:
class Table(BaseModel):
id_field = CharField(primary_key=True)
See this link on non-integer primary keys documentation