title: SQLAlchemy relationship problems - mapper fails to locate name
body: <p>I have two tables where I'm trying to set up a one-to-many relationship. There should be a single <code>Player</code> with multiple <code>Sessions</code>. </p>
  
  <pre><code>import sqlalchemy as sql
  from sqlalchemy.orm import relationship
  from sqlalchemy.ext.declarative import declarative_base
  
  Base = declarative_base()
  
  class Session(Base):
      __tablename__ = 'session'
  
      id = sql.Column('session_id', sql.INTEGER, primary_key=True)
      player_id = sql.Column(sql.INTEGER, sql.ForeignKey('player.player_id'))
  
  class Player(Base):
      __tablename__ = 'player'
  
      id = sql.Column('player_id', sql.INTEGER, primary_key=True)
      sessions = relationship('Session', backref='player')
  </code></pre>
  
  <p>However, the error I keep getting when creating the database is </p>
  
  <pre><code>sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - 
  can't proceed with initialization of other mappers. Triggering mapper: 
  'Mapper|Player|player'. Original exception was: When initializing mapper 
  Mapper|Player|player, expression 'Session' failed to locate a name ("name 
  'Session' is not defined"). If this is a class name, consider adding this 
  relationship() to the &lt;class 'analysis_db_tables.Player'&gt; class after both 
  dependent classes have been defined.
  </code></pre>
  
  <p>I've tried switching the order of <code>Player</code> and <code>Session</code>, removing the <code>relationship</code> line down outside of <code>Player</code> as</p>
  
  <pre><code>Player.sessions = relationship('Session', backref='player')
  </code></pre>
  
  <p>and I've also tried using <code>back_populates</code> with <code>relationship</code> statements in both classes. What am I doing wrong here?</p>
  
  <p>This issue popped up seemingly randomly while building my database code, and I've paired down the tables to just these two while still recreating the problem. I'm using SQLAlchemy with postgres. Thanks.</p>