SQLite parameter substitution and quotes

To anyone who like me found this thread and got really frustrated by people ignoring the fact that sometimes you can’t just ignore the quotes (because you’re using say a LIKE command) you can fix this by doing something to the effect of:

var = name + "%"
c.execute('SELECT foo FROM bar WHERE name LIKE ?',(var,))

This will allow you to substitute in wildcards in this situation.

Leave a Comment