I am receiving this error:
File "/DateDbLoop.py", line 33
d.Id""" % (str(day), str(2840))"
^
SyntaxError: EOL while scanning single-quoted string
Here is the script. There are 4 double quotes to open this, but I am unsure how to correctly close this out?
Follow Up Question:
Does this % (str(day), str(2840)) need to go in both the sql variable and the os.system() call?
#!/usr/bin/python
import datetime
import sys, os, time, string
a = datetime.date(2009, 1, 1)
b = datetime.date(2009, 2, 1)
one_day = datetime.timedelta(1)
day = a
while day <= b:
print "Running query for \"" + str(day) + "\""
sql=""""SELECT
d.Date,
SUM(d.Revenue),
FROM Table d
WHERE d.Date = '%s'
AND d.Id = %s
GROUP BY d.Date
""" % (str(day), str(2840))"
os.system('mysql -h -sN -u -p -e %s > FileName-%s.txt db' % (sql, str(day)))
day += one_day