Well, I haven't really figured out why this is happening, but I did find a 
workaround that works for me:

I replaced 
act like '%%:correct'

with 
position('correct' in act) > 0)

This works because I'm simply trying to find if the act value contains 
'correct'. I'd still love to know why my original approach didn't work, 
however.



On Monday, July 1, 2013 10:04:19 AM UTC-5, Isaac Dontje Lindell wrote:
>
> I'm trying to run this query using db.executesql().  I'm doing the string 
> substitution (with the variable 'sid') before passing the query to 
> executesql(), although I've also tried just passing the tuple (sid, sid) as 
> the 'placeholders=' param to executesql, with the same results.
>
> I can run this query (with 'sid' manually substituted) using psql and get 
> a valid answer. But when running with executesql, it throws a
>  QueryParameterParseError: '%:' not supported in quoted string.
>
> The issue seems to be with the % wildcard (..act like '%%:correct'). I can 
> print out the string after the substitutions have happened, and the percent 
> symbol seems to have been properly escaped - i.e. the double percent is 
> replaced by a single percent symbol.
>
> '''select (select cast(count(*) as float) from useinfo where sid='%s' and 
> event='mChoice' and act like '%%:correct' )
> / 
> (select cast(count(*) as float) from useinfo where sid='%s' and event='
> mChoice' ) as result;
> ''' % (sid, sid)
>
> Is this a bug in PG8000? I did find 
> this<https://groups.google.com/forum/#!topic/web2py/Gys8B5Y_hIQ> thread, 
> but it seems to be more related to inserting a string containing the 
> literal % rather than that using % as a wildcard.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to