Missing closing single quote. Also, if we're already touching this, we probably need proper handling (doubling) of single quotes in the value -- so, something like `"'%s'" % value.replace("'","''")`