Why does the 1st query fail, whilst the 2nd succeeds, although the SQL
is identical?

The 1st query indeed returns the error: "OperationalError: no such
column: 'FR'".

query = """
SELECT book_foreign_print.book_id, book_foreign_print.date,
book_foreign_print.country_id
FROM book_foreign_print, book_country
WHERE
    book_foreign_print.country_id = book_country.name
    %s
""" % (
    countries and 'AND book_foreign_print.country_id IN (%s)' %
countries or ''
)
cursor.execute(query)

where countries='FR,GB', and:

query = """
SELECT book_foreign_print.book_id, book_foreign_print.date,
book_foreign_print.country_id
FROM book_foreign_print, book_country
WHERE
    book_foreign_print.country_id = book_country.name
    %s
""" % (
    countries and 'AND book_foreign_print.country_id IN (%s)' %
','.join(['%s'] * len(countries)) or ''
)
cursor.execute(query, countries)

where countries=['FR', 'GB']


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to