KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the following models: class Look(Base): __tablename__ = "looks" id = Column(Integer, primary_key=True) url = Column(String, nullable=False, unique=True) class Similarity(Base): __tablename__ = 'similarities' __table_args__ = (UniqueConstraint('look_id_small', 'look_id_big'),) id = Column(Integer, primary_key=True) look_id_small = Column(Integer, ForeignKey('looks.id'), nullable=False) look_id_big = Column(Integer, ForeignKey('looks.id'), nullable=False) When I am running this code: try: with session.begin_nested(): similarity = Similarity() similarity.look_id_small, similarity.look_id_big = look_id1, look_id2 session.add(similarity) session.commit() except Exception, e: logging.error(e) print "look_id1: %s, look_id2: %s" % (look_id1, look_id2) This is the error I am getting: 2013-01-19 04:55:42,974 ERROR Foreign key associated with column 'similarities.look_id_small' could not find table 'looks' with which to generate a foreign key to target column 'id' look_id1: 217137, look_id2: 283579 so I tried looking for these values in pgsql and they do exist! giordano=# SELECT * FROM looks WHERE id = 217137 or id = 283579; id | url | title | image_url | --------+-----------------------------------------------+-------+-----------+ 217137 | http://foo.com | | | 283579 | http://baz.com | | | (2 rows) I have spent the whole night trying to figure this out. Some clues: I am only getting these errors on certain values. I don't think having double foreignkeys on the same table will result in an issue. Anyone? EDIT: giordano=# \d+ looks
Tags (comma-separated)
Save Edits
Cancel