Hi,

When I  tested sql of MySQL in Python interactive shell, I got an
error of "not enough arguments for format string". I checked the
arguments however I could not find anything wrong.

Can anybody give me a clue?

Thanks so much.


>>> sql = Template('select dimension1 ,adddate(current_date,-1),current_date, 
>>> ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = 
>>> adddate(current_date,-1) then ifnull($ss_1,0) end),0) as \'PreviousDay\', 
>>> ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = current_date 
>>> then ifnull($ss_2,0) end),0) as \'Today\' from   message_alert where  
>>> dataset_id = $ss_3 and dimension1 in ($ss_4) and    hour(creation_date) = 
>>> hour(now())-1 group by dimension1 having (ifnull(sum(case when 
>>> date_format(creation_date,\'%Y-%m-%d\') = current_date then ifnull($ss_5,0) 
>>> end),0) / ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = 
>>> adddate(current_date,-1) then ifnull($ss_6,0) end),0)) $ss_7   $ss_8')

>>>
>>> sql = sql.substitute(ss_1='metric1', ss_2='metric1', ss_3=2, 
>>> ss_4='557796,558069,558230', ss_5='metric1', ss_6='metric1', ss_7='>=', 
>>> ss_8=0.05)
>>>


>>> cursor.execute(sql)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
line 22, in execute
    sql = self.db.ops.last_executed_query(self.cursor, sql, params)
  File "/usr/lib/python2.5/site-packages/django/db/backends/
__init__.py", line 217, in last_executed_query
    return smart_unicode(sql) % u_params
TypeError: not enough arguments for format string
>>>



--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to