I have to run the following SQL query:

query = """SELECT offers_offer.id FROM offers_offer \
               WHERE offers_offer.category_id IN %s \
               AND offers_offer.from_date <= %s \
               AND offers_offer.to_date >= %s \
               ORDER BY (original_price-discounted_price)/
(original_price*1.0) DESC"""

cursor.execute(query, [(1, 2, 3), datetime.date.today(),
datetime.date.today()])

But I get the following error:
Traceback (most recent call last):
  File "<pyshell#385>", line 1, in <module>
    cursor.execute(query, [(1, 2, 3), datetime.date.today(),
datetime.date.today()])
  File "C:\Python25\lib\site-packages\django\db\backends\util.py",
line 12, in execute
    return self.cursor.execute(sql, params)
  File "C:\Python25\lib\site-packages\django\db\backends
\sqlite3\base.py", line 94, in execute
    return Database.Cursor.execute(self, query, params)
OperationalError: near "?": syntax error

The error seems to be due to the first parameter (which is the tuple
(1, 2, 3)) because when I remove that parameter and the corresponding
condition the problem disappear. Converting the tuple to a string
before passing doesn't help solving the problem.

Any idea of what I'm doing wrong?

Many thanks
Francesco


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to