示例:html
Lobby.query.filter(sql
or_(app
and_(ide
Lobby.id == Team.lobby_id,函數
LobbyPlayer.team_id == Team.id,url
LobbyPlayer.player_id == player.steamidspa
),code
and_(orm
Lobby.id == spectator_table.c.lobby_id,htm
spectator_table.c.player_id == player.steamid
)
)
)
https://stackoverflow.com/questions/13370993/sqlalchemy-query-and-or-issue
from sqlalchemy import or_,and_
@app.route('/search/') def search(): qu=request.args.get('q') ques=Question.query.filter( or_( Question.title.contains(qu), Question.detail.contains(qu) ) ).order_by('-creat_time') return render_template('index.html',questions=ques)
daohang.html:
<form action="{{ url_for('search') }}" method="get" class="navbar-form navbar-left"> <input name="q" type="text" class="form-control" placeholder="請輸入關鍵字"> <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>查找</button> </form>