Chrome Extension

Using and on filter query SQLAlchemy

We can apply AND operator on the SQLAlchemy filter query where it will filter the result if both conditions are matched.
from sqlalchemy import and_

session.query(
    UserModel.id,
    UserModel.first_name
).filter(
    and_(
        UserModel.first_name == 'john', 
        UserModel.last_name == 'michael'
    )
).all()
Code faster with devsheet chrome extension and increase productivity as a programmer
search code from your favorite search engine instantly.
Install Now

Search Index Data (The code snippet can also be found with below search text)

and_ SQLAlchemy
Was this helpful?
0 Comments
Open Code Manager We are hiring