Что я здесь делаю не так? Я попытался следовать примеру, приведенному в документации, но столкнулся с ошибкой, связанной с тем, что таблица не существует.
Я использую sqlite-db для тестирования.
class PredictionMeta(SQLModel, table=True):
id: int = Field(primary_key=True)
run_id: str = Field(unique=True, index=True)
class PredictionMonths(SQLModel, table=True):
id: int = Field(primary_key=True)
run_id: str = Field(foreign_key="PredictionMeta.run_id", index=True)
month: str
prediction: float
class PredictionModel(SQLModel, table=True):
id: int = Field(primary_key=True)
run_id: str = Field(foreign_key="PredictionMeta.run_id", index=True)
material: str
SQLModel.metadata.create_all(engine)
NoReferencedTableError: Foreign key associated with column 'predictionmonths.run_id' could not find table 'PredictionMeta' with which to generate a foreign key to target column 'run_id'
Подробнее здесь: https://stackoverflow.com/questions/790 ... h-sqlmodel