I'm getting an error replacing the %s to a date string.
import datetime
now = datetime.datetime.now()
day_minus_one = now + datetime.timedelta(days=-1)
new_date = day_minus_one.strftime('%Y%m%d')
db = MySQLdb.connect(host='127.0.0.1', user='root', passwd='', db='daily_report')
cur = db.cursor()
sql = "select date, stp_dpc, count(*), concat(round(avg(status = 'Success') * 100), '%') as Success from daily where status not in ('data1', 'data2', 'data3') and date = %s group by date, stp_dpc"
cur.execute(sql, new_date)
rows = cur.fetchall()
If i replace the equals to a literal string = '20170327' it does work perfectly.
cur.execute("select date, stp_dpc, count(*), concat(round(avg(status = 'Success') * 100), '%') as Success from daily where status not in ('data1', 'data2', 'data3') and date = '20170310' group by date, stp_dpc")
rows = cur.fetchall()
strftimeto coerce the value into the right format. ISO 8601 is preferred:YYYY-MM-DD.