I'm stuck on the error in the title of this post. I have a table Question that has a double connection (one to one and one to many) with another table Answer. I can create the tables, but I can't drop them for some reason.
I tried to add a "primary join" argument as suggested in this post but to no avail.
Why is this code failing?
#Initialize database
db = SQLAlchemy(app)
class Question(db.Model):
__tablename__ = "Question"
id = Column(Integer, primary_key=True)
question = Column(String(256),nullable=False)
correct_answer_id = Column(Integer,ForeignKey('Answer.id'))
correct_answer = relationship("Answer",foreign_keys=[correct_answer_id],uselist=False,primaryjoin="Question.correct_answer_id==Answer.id")
answers = relationship("Answer", backref="Question", primaryjoin="Question.id==Answer.question_id")
class Answer(db.Model):
__tablename__ = "Answer"
id = Column(Integer, primary_key=True)
question_id = Column(Integer, ForeignKey('Question.id'),nullable=False)
answer = Column(String(256))
db.drop_all()
db.create_all()