Relative Content

Tag Archive for pythonpostgresqlsqlalchemy

How to create a relationship between two tables while joining to another table in sqlalchemy?

I am trying to create sqlalchemy relationship between two tables which relies on a value of another table. My UserSports table has a relationship with the Baseball table (as well as other sports that they may have played). I also have a Sports enums table which joins to the Users table. The goal is to create a relationship between UserSports and Baseball using Sports enums. user_sports.id and baseball.user_sport_id is a one-to-one relationship. The sql would be something like: