Re: MySQL Django Wildcard bug...
On 8 Sep 2006, at 22:53, James Bennett wrote: > > On 9/8/06, tom smith <[EMAIL PROTECTED]> wrote: >> Then because the sql has a % in it.. django complains... > > The '%' needs to be escaped, because it's a special character in this > context. Make it '%%' (two percent signs in a row) and it should work > (and this isn't Django-specific AFAIK -- the syntax comes straight out > of the standard Python DB-API). Blimey!... thanks what a weird thing... I would NEVER have got that... Big big thanks! > "May the forces of evil become confused on the way to your house." ..as I generally do... er.. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: MySQL Django Wildcard bug...
On 09/08/06 22:56, tom smith wrote: > So... > > Because there aren't quite enough examples that show how to build > pythonic model queries... I'm using the pump-raw-sql at django... > > The only problem is that when my sql contains > > wordsql = wordsql + " AND (title not like ' %" + word +"%') " > > cursor.execute(sql) > > Then because the sql has a % in it.. django complains... > > "not enough arguments for format string" > > which I think is because the % is somehow being seen as a %s.. > > basically... pumping raw sql is fine unless theres a "%" in there... > > > any ideas? > Try escaping the %. e.g. wordsql = wordsql + " AND (title not like ' %%" + word +"%%') " --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: MySQL Django Wildcard bug...
On 9/8/06, tom smith <[EMAIL PROTECTED]> wrote: > Then because the sql has a % in it.. django complains... The '%' needs to be escaped, because it's a special character in this context. Make it '%%' (two percent signs in a row) and it should work (and this isn't Django-specific AFAIK -- the syntax comes straight out of the standard Python DB-API). -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
MySQL Django Wildcard bug...
So... Because there aren't quite enough examples that show how to build pythonic model queries... I'm using the pump-raw-sql at django... The only problem is that when my sql contains wordsql = wordsql + " AND (title not like ' %" + word +"%') " cursor.execute(sql) Then because the sql has a % in it.. django complains... "not enough arguments for format string" which I think is because the % is somehow being seen as a %s.. basically... pumping raw sql is fine unless theres a "%" in there... any ideas? thanks tom p.s or... how do I create a pythonic query where I a > v a < w b not like x b not like y b not like z c not like e --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---