0

Trying to find a way to make a query using ilike or like operators in one of my routes . See below . So if i query for 'john' in my layer it should get all the available non sensitive %john% in my database. Could you please advise how i could better structure my route and function ?

@app.route('/layers/')
def layer_search():
    layer = request.args.get('layer')
    if layer is None or len(layer) != 0:
            query = Layers.query.filter_by(name=layer)
            print query
            return render_template('layers.html', query=query, header=header)
    else:
        return render_template('layers.html', header=header)
Jorge Vidinha
  • 404
  • 7
  • 20

1 Answers1

0

You should be able to just do something like:

 Layers.query.filter(Layer.name.ilike(layer)).all()
reptilicus
  • 10,290
  • 6
  • 55
  • 79