title: How to use function to verify password inside sqlalchemy query?
body: <p>How to use function to verify password inside sqlalchemy query ?
  In </p>
  
  <pre><code>class PersonModel(Base):
      __tablename__ = 'persons'
      username = Column(String(30), nullable=False)
      email = Column(String(75), nullable=False)
      password = Column(String(128), nullable=False)
  </code></pre>
  
  <p>I store password using <code>sha256_crypt.encrypt("password_string")</code> from <a href="http://pythonhosted.org/passlib/" rel="nofollow">http://pythonhosted.org</a>/passlib/ and I can verify with <code>sha256_crypt.verify(password_to_check_against, hash)</code></p>
  
  <p>( tried like </p>
  
  <pre><code>person = session.query(PersonModel).filter(and_(PersonModel.username.like(username), PersonModel.password.like(sha256_crypt.encrypt(password_string)))).first()
  </code></pre>
  
  <p>but it doesn't work => sha256_crypt.encrypt(password_string) generates different value than in db for same password and I cannot use <code>==</code> operator only <code>sha256_crypt.verify</code> from site)
  How to inject this in my query ?</p>