Skip to content

Instantly share code, notes, and snippets.

@inklesspen
Created July 6, 2010 16:44
Show Gist options
  • Select an option

  • Save inklesspen/465613 to your computer and use it in GitHub Desktop.

Select an option

Save inklesspen/465613 to your computer and use it in GitHub Desktop.
# you may need to use the foreign_keys or primaryjoin arguments on the relationship
class Door(Base):
__tablename__ = "doors"
locked = Column(Boolean)
side_a_id = Column(Integer, ForeignKey("rooms.id"), nullable=False)
side_a = relationship(Room)
side_b_id = Column(Integer, ForeignKey("rooms.id"), nullable=False)
side_b = relationship(Room)
class Room(Base):
__tablename__ = "rooms"
id = Column(Integer, primary_key=True)
appearance = Column(String)
doors = relationship(Door)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment