[Flask] Problem with sqlite3 LIKE clause

Tom madtom1999 at googlemail.com
Tue Jan 10 06:37:34 EST 2017


I'm trying to modify the flaskr tutorial to make a full blown wiki using 
ckeditor and its mostly working ok - bar the search.
There is a field 'description' which is meant to contain words and 
phrases for searching.
I wish to search a text field in the database but cannot get anything 
other than the following to parse:

     searchstring=request.form['searchstr'];
     cur = g.db.execute('select * from entries where description like 
(?) order by id desc',(searchstring,))

any attempts to add %'s etc seem lead to failure. I can build the sql 
string myself but would like to make it safe.
Any ideas how to do this?
Tom


More information about the Flask mailing list