Hi,

what is wrong with this query?

user_id_tuple = (2, 3, 25, 15) # for example
cursor = connection.cursor()
cursor.execute(""""SELECT
                        week, year, SUM(data), SUM(data1), SUM(data2),
SUM(data3),
                        SUM(data4) FROM user_table
                        WHERE user_id IN %s GROUP BY week, year
                        ORDER BY year, week""" , [user_id_tuple])

Django gives me OperationalError when I try to run it. I tried the
same query with mysql on different server(same django version) and it
worked great.

Part of error raport:
Exception Type:         OperationalError
Exception Value:        near "?": syntax error
Exception Location:     C:\Python25\Django\django\db\backends
\sqlite3\base.py in execute, line 136

C:\Python25\Django\django\db\backends\util.py in execute

  11. def __init__(self, cursor, db):
  12. self.cursor = cursor
  13. self.db = db # Instance of a BaseDatabaseWrapper subclass
  14. def execute(self, sql, params=()):
  15. start = time()
  16. try:
  18. return self.cursor.execute(sql, params)

C:\Python25\Django\django\db\backends\sqlite3\base.py in execute

 129. """
 130. Django uses "format" style placeholders, but pysqlite2 uses
"qmark" style.
 131. This fixes it -- but note that if you want to use a literal "%s"
in a query,
 132. you'll need to use "%%s".
 133. """
 134. def execute(self, query, params=()):
 135. query = self.convert_query(query, len(params))

 136. return Database.Cursor.execute(self, query, params)

--~--~---------~--~----~------------~-------~--~----~
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