Re: [pysqlite] Escaping chars and LIKE statements
"Nemanja Čorlija" <[email protected]> Fri, 18 Apr 2008 14:20:01 +0200
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Apr 18, 2008 at 1:37 PM, Adrián Bravo Navarro <[email protected]> wrote: > hi, > > Im trying to get this statement work: > > cur.execute("select * from history where timestamp "+timecondition+"? and " > +"(finalpath like ?/% or finalpath like ?) order by timestamp > DESC",(timestamp,path,path)) > > For some reason, ? and % dont get on well, and the statement crashes near %. > Whats the way to escape that and keep it working? > You need to have your wild cards as part of string you're binding. So your code should look something like this: cur.execute("select * from history where timestamp "+timecondition+"? and (finalpath like ? or finalpath like ?) order by timestamp DESC", (timestamp,path+"/%",path)) -- Nemanja Čorlija <[email protected]> _______________________________________________ list-pysqlite mailing list [email protected] http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite