[Answered ]-Why will these strings not be quoted by psycopg2 for the query?

1๐Ÿ‘

โœ…

str(query) only returns an approximative representation of the query. Are you trying to pass it to the database?

The query issued with iexact seems correct with Django 1.2.3. The above would result in WHERE UPPER("addr2zip"."street_name"::text) = UPPER(E'Common Ground'). Which version are you using?

๐Ÿ‘คpiro

1๐Ÿ‘

To get the query to be executed, use something like:

from django.db import DEFAULT_DB_ALIAS
queryset.query.get_compiler(DEFAULT_DB_ALIAS).as_sql()
๐Ÿ‘คpkoch

0๐Ÿ‘

But you just pasted it like that yourself:

where = ['ctystate.zip5 = addr2zip.zip5 AND ctystate.city_name = %s' % 'Philipsburg'],

so you got query string constructed with syntax error:

AND ctystate.city_name = Philipsburg
๐Ÿ‘คcababunga

Leave a comment