示例
from sqlalchemy import create_engine, MetaData, and_, or_, TIMESTAMP
Plugin.query.filter(and_(Plugin.job_name == job_name, or_(Plugin.group_id.is_(None), Plugin.group_id == delete_list[0]),
Plugin.plugin_name == delete_list[1], Plugin.plugin_version == delete_list[2],
Plugin.plugin_state == delete_list[3])).delete()
from django.db.models import Q
Plugin.objects.filter(
Q(job_name=job_name, group_id=None, plugin_name=delete_list[1], plugin_version=delete_list[2],
plugin_state=delete_list[3]) |
Q(job_name=job_name, group_id=delete_list[0], plugin_name=delete_list[1],
plugin_version=delete_list[2], plugin_state=delete_list[3])
).delete()
更多操作符
见/Users/xxx/.virtualenvs/erebus_app/lib/python3.6/site-packages/sqlalchemy/sql/operators.py
比如:startwith/endwith/contains/asc/desc/is_/isnot