python将图片写入数据库 sql语句报错

python语句如下
data 为二进制读取的图片文件

cur.execute("INSERT INTO `data_collect`.`image_data`(`time`, `value`) VALUES (%d, %s)" % (count, pymysql.Binary(data)))

这个是报错信息

pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'b'\\xff\\xd8\\xff\\xdb\\x00\\x84\\x00\\x02\\x01\\x01\\x02\\x01\\x01\\x02\\x02\\x01\\x02\\x02\\x02\\x' at line 1")
根据网上的解决办法 去掉了%s的引号 依旧报错 求大佬dian'bo

pymysql.Binary(data)
输出下这个参数,里面包含非法字符。另外图片是二进制,怎么用%s格式化呢

现在这个问题解决了吗