Flask - MySQL You have an error in your SQL syntax

Viewed 18

I'm trying to delete an item from MySQL database, but I'm getting the following error message:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

What am I doing wrong? In both cur.execute cases I'm getting the same response.

from flask_mysql_connector import MySQL

@app.route('/delete/<id>', methods=['DELETE'])
def delete_contact(id):    
    conn = mysql.connection
    cur = conn.cursor()
    # cur.execute('DELETE FROM `farm-users`.users WHERE id = {}'.format(id))
    cur.execute("DELETE FROM `farm-users`.users WHERE id = %s" % (id))
    conn.commit()
    return 'user deleted'
0 Answers
Related