I'm trying to run a delete query using MySQLdb and passing 3 variables. The query is run as follows:
self.cursor.execute("""DELETE er.* FROM extension_recording er,
extension e, client c
WHERE er.extension_id = e.id AND e.client_id = c.id
AND c.parent_client_id = %s
AND DATE(er.cr_date) BETWEEN '%s' AND '%s'""" ,
(client_id, start_date, end_date))
Please excuse the indenting, couldn't seem to make it legible without.
And what happens is this: TypeError: not all arguments converted during string formatting
I've tried passing the SQL to the cursor as a string (I know this is vulnerable to SQL injection, was just testing) and the result is the same. I've examined the SQL and it seems fine.
Is this something to do with the single quoted dates in the query? Or something else?
BETWEEN '%s' AND '%s'toBETWEEN %s AND %s? If not, what are the types ofclient_id,start_date, andend_date?DELETE er.* FROM extension_recording er, extension e, client c WHERE er.extension_id = e.id AND e.client_id = c.id AND c.parent_client_id = 0009 AND DATE(er.cr_date) BETWEEN '2013-05-01' AND '2013-05-15'