title: Comparing two tables using flask-sqlalchemy
body: <p>I'm starting my adventure with python and flask.</p>
  
  <p>I'm using Flask-SQLAlchemy for MySQL/MariaDB task</p>
  
  <pre><code>class Local(db.Model):
      __tablename__ = 'local'
      id = db.Column("VideoLocalID", db.Integer, primary_key=True)
      file_path = db.Column("FilePath", db.String)
      hash = db.Column("Hash", db.String)
  
  class Remote(db.Model):
      __tablename__ = 'remote'
      id = db.Column("EpisodeID", db.Integer, primary_key=True)
      # hash = db.relationship('Local', backref='hash', lazy='dynamic')
      hash = db.Column("Hash", db.String)
      #hash = db.relationship(db.String, db.ForeignKey('local.hash'))
      percentage = db.Column("Percentage", db.Integer)
  </code></pre>
  
  <p>I'm trying to get all the items that don't "hash" don't exist in both tables. I'm interested only in items that are in Local table.</p>
  
  <p>Like you see I tried to make FK work but without success</p>
  
  <pre><code>localv = Local.query.all()
  remotev = Remote.query.all()
      for video in localv:
          for video_remote in remotev:
              #checking if there is a match if not adding to list
  </code></pre>
  
  <p>I think that my double for loop is bad. Is there a way to speed this up, or even make it do in database instead of local?</p>