Re: [pysqlite] Escaping chars and LIKE statements
"Adrián Bravo Navarro" <[email protected]> Fri, 18 Apr 2008 16:45:25 +0200
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
2008/4/18, Nemanja Čorlija <[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)) Thanks, I've put it to work with that, bu I've also added an extra % because sqlite get it as the char "%". Adrián -- > Nemanja Čorlija <[email protected]> > _______________________________________________ > list-pysqlite mailing list > [email protected] > http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite _______________________________________________ list-pysqlite mailing list list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite