오류
sqlalchemy.exc.NoForeignKeysError
: Could not determine join condition between parent/child tables on relationship FaceRequestsDB.facial_expression - there are no foreign keys linking these tables. Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify a 'primaryjoin' expression.
(...중간 생략)
File "/경로/경로/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
sqlalchemy.exc.NoForeignKeysError: Could not determine join condition between parent/child tables on relationship FaceRequestsDB.facial_expression - there are no foreign keys linking these tables. Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify a 'primaryjoin' expression.
원인
facial = relationship 으로 FacialDB로 연결해놨는데 컬럼에는 어디에 사용한다는 foreignkey를 명시한게 없어서 오류가 발생
class FaceRequestsDB(Base):
__tablename__ = 'face_requests'
id = Column(Integer, primary_key=True, index=True)
user_id = Column(ForeignKey('users.id'), index=True)
(...중간생략)
format = Column(String(45))
user = relationship('UsersDB')
facial = relationship('FacialDB')
해결
class FaceRequestsDB(Base):
__tablename__ = 'face_requests'
id = Column(Integer, primary_key=True, index=True)
user_id = Column(ForeignKey('users.id'), index=True)
(...중간생략)
format = Column(String(45))
facial_id = Column(ForeignKey('facial.id'), index=True) # 수정 부분
user = relationship('UsersDB')
facial = relationship('FacialDB')
'Error' 카테고리의 다른 글
[Error] type_error.dict : value is not a valid dict (1) | 2024.12.22 |
---|---|
[Error] ZeroDivisionError (1) | 2024.12.22 |
[Error] io.UnsupportedOperation: read (0) | 2024.12.22 |
[Error] binascii.Error: Invalid base64-encoded string (0) | 2024.12.21 |
[Error] StopIteration (0) | 2024.12.21 |