我试图将Data Classes映射到SQL炼金术declarative表,但当我尝试实例化数据类对象时,出现以下错误:sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column 'runs.experiment_uuid' could not find table 'experiments' with which to generate a foreign key to target column 'experiment_uuid'
SQL炼金术表定义:
^{pr2}$
数据类:@dataclass
class Experiment:
experiment_uuid: str
experiment_config: dict
creation_date: datetime
@dataclass
class Run:
run_uuid: str
experiment_uuid: str
run_time: datetime
user_metadata: dict
映射:from sqlalchemy.orm import mapper
mapper(Experiment, db_schema.Experiment.__table__)
mapper(Run, db_schema.Run.__table__)
最后,当我尝试实例化和实验时,我得到了一个错误:self.experiment = Experiment(
experiment_uuid=str(uuid.uuid1()),
experiment_config=self.config,
creation_date=datetime.now().timestamp()
)