标签:lis nal comm size sha sed out query sep
query.filter(User.name == ‘leela‘)
query.filter(User.name != ‘leela‘)
query.filter(User.name.like(‘%leela%‘))
query.filter(User.name.in_([‘leela‘, ‘akshay‘, ‘santanu‘]))
# works with query objects too:
query.filter(User.name.in_(session.query(User.name).filter(User.name.like(‘%santanu%‘))))
query.filter(~User.name.in_([‘lee‘, ‘sonal‘, ‘akshay‘]))
filter(User.name == None)
filter(User.name != None)
from sqlalchemy import and_
filter(and_(User.name == ‘leela‘, User.fullname == ‘leela dharan‘))
#or, default without and_ method comma separated list of conditions are AND
filter(User.name == ‘leela‘, User.fullname == ‘leela dharan‘)
# or call filter()/filter_by() multiple times
filter(User.name == ‘leela‘).filter(User.fullname == ‘leela dharan‘)
from sqlalchemy import or_
filter(or_(User.name == ‘leela‘, User.name == ‘akshay‘))
query.filter(User.name.match(‘leela‘))
SQLAlchemy query with OR/AND/like common filters
标签:lis nal comm size sha sed out query sep
原文地址:http://www.cnblogs.com/ymy124/p/6128602.html