I'm trying to do a little program for print an user that it was selected in a list. But I don't know how to mix a variable with a query. I tried this but I get an error:
def datos(name):
conn = MySQLConnection(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_NAME)
cursor = conn.cursor()
cursor.execute("SELECT nombre FROM clientes WHERE nombre = %s", name)
Error:
mysql.connector.errors.ProgrammingError: 1064 (42000): 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 '%s' at line 1