How do I do real escaping in Python for SQLite3?
If I have Google for it (or to search for stackoverflow), there are a lot of questions for this, and each time the answer is something like:
dbcursor.execute("SELECT * FROM `foo` WHERE `bar` like ?", ["foobar"])
This helps against SQL injection, and this is enough if I only did compilations with "=", but this, of course, does not break Wildcards.
So if i do
cursor.execute(u"UPDATE `cookies` set `count`=? WHERE `nickname` ilike ?", (cookies, name))
some user could put "%" for an alias and replace all cookies with one line. I could filter it myself (pah ... I probably still forget one of these lesser-known wildcards), I could use lowercase letters with nick and nickname and replace "ilike" with "=", but then what I really would like to do would be something like:
foo = sqlescape(nick)+"%"
cursor.execute(u"UPDATE `cookies` set `count`=? WHERE `nickname` ilike ?", (cookies, foo))