I'm currently working on a python project using peewee to connect to MySQLDatabase.
If I want to create a table using
database.create_tables(tables=[]) (create_table does not work)
I get the following error message from my logger:
ERROR session[5924]: (1005, 'Can't create table example_database.example_table (errno: 150 "Foreign key constraint is incorrectly formed")')
example_table is specified as:
class Example_Table(BaseModel):
id = PrimaryKeyField()
example_table2 = ForeignKeyField(Modul)
class Meta:
db_table = 'Example_Table'
BaseModel is defined as follows:
class BaseModel(Model):
class Meta:
database = database
and database is my MySQLDatabase Object.
The Problem is, why doesnt the foreign key constraint work and why are the tables all saved in Lowercase, but I defined them in Uppercase
If I run the program again, It creates the tables but gives me a duplicate key_name error
Version: peewee==3.0.17