4
我使用的SQLAlchemy在下面創建兩張表:sqlalchemy.exc.ProgrammingError:(ProgrammingError)沒有唯一約束匹配給定鍵引用的表
class Classroom(Base):
__tablename__ = 'classroom'
building = Column(String(256), primary_key = True)
room_no = Column(String(256), primary_key = True)
capacity = Column(Integer)
class Section(Base):
__tablename__ = 'section'
course_id = Column(String(256), ForeignKey('course.course_id'), primary_key = True)
building = Column(String(256), ForeignKey('classroom.building'))
room_no = Column(String(256), ForeignKey('classroom.room_no'))
但是,我得到的錯誤說:
sqlalchemy.exc.ProgrammingError: (ProgrammingError) there is no unique constraint matching given keys for referenced table "classroom"
感謝您跟進,當你想出來,而不是放棄這個問題。 –