title: How to fix sqlalchemy.exc.IntegrityError for one to one relationship Flask SQL Alchemy
body: <p>I am trying to a 1 to 1 join with Flask SQL Alchemy but unfortunately I run into the following errors:</p>
  <pre><code>sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column &quot;tablea_id&quot; of relation &quot;tableb&quot; violates not-null constraint
  DETAIL:  Failing row contains (1, US, accountant, null).
  </code></pre>
  <p>I just implementing recommendations on several stackoverflow questions and answers such as this one: <a href="https://stackoverflow.com/questions/39869793/when-do-i-need-to-use-sqlalchemy-back-populates">When do I need to use sqlalchemy back_populates?</a> but its not working for me.</p>
  <p>Here is the snipnet of my code for your perusal:</p>
  <pre><code>class TableA(UserMixin, db.Model):
      __tablename__ = &quot;table_a&quot;
      __table_args__ = {&quot;schema&quot;: &quot;db_name&quot;}
      id = db.Column(db.Integer, primary_key=True)
      age= db.Column(db.Integer, nullable=False)
      height= db.Column(db.Integer, nullable=False)
      salary = db.Column(db.Integer)
  
      tableb = relationship(&quot;TableB&quot;, uselist=False, backref=&quot;tablea&quot;)
  
  
  class TableB(UserMixin, db.Model):
      __tablename__ = &quot;table_b&quot;
      __table_args__ = {&quot;schema&quot;: &quot;db_name&quot;}
      id = db.Column(db.Integer, primary_key=True)
      branch = db.Column(db.String(10), nullable=False)
      goal = db.Column(db.String(50), nullable=False)
  
      tablea_id = db.Column(db.Integer, db.ForeignKey(TableA.id), nullable=False)
  </code></pre>