Python SQLite parameter substitution with wildcards in LIKE
The quotes protect either ?
or :name
from being taken as a place-holder -- they're taken literally. You need to place the percent signs around the string you're passing, and use the plain placeholder without quotes. I.e.:
self.cursor.execute(
"select string from stringtable where string like ? and type = ?",
('%'+searchstr+'%', type))
Note that neither ?
is in quotes -- and that's exactly as it should be for them to be taken as placeholders.