#20 unsupported format character 'D' (0' (0x

MySQLdb-1.0
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2001-11-22
Anonymous
No

I don't know if this is a bug, but this is the error
message:

unsupported format character 'D' (0' (0x

This is the SQL:

        cur.execute(
                    """
                    SELECT
                    b.company_name,
                    b.contact_title,
                    b.fname,
                    b.lname,
                    b.addr1,
                    b.addr2,
                    b.addr3,
                    b.town,
                    b.postcode,
                    w.warranty_no,

DATE_FORMAT(w.valid_from_date, '%D of %M %Y'),
DATE_FORMAT(w.valid_to_date,
'%D of %M %Y')
FROM
warranty w,
bus_cust b
WHERE
w.warranty_no = %s
AND
b.cust_id = w.customer_id
""", (warranty_no))

Discussion

  • Andy Dustman
    Andy Dustman
    2001-11-24

    Logged In: YES
    user_id=71372

    Not a bug. Since MySQLdb uses the python % operator on the
    query string, any percent signs which are part of your SQL
    must be doubled, i.e. you need '%%D of %%M %%Y'