My query on execution of this fails:
cursor.execute(\"SELECT name FROM products WHERE rating > %s AND category like \'Automation %\'\", (3));
You can probably escape it using an extra %:
%
cursor.execute("SELECT name FROM products WHERE rating > %s AND category like 'Automation %%'", (3));
This apparently works for MySQLdb and I would expect it to work for python-mysql as well. . .