0

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
2
  • 1
    You might find you need to use e.g. ? instead of %s for that system - have you read the manual? Commented Oct 6, 2015 at 15:58
  • No. It doesn't work. I have the same error but ? instead of %s. Commented Oct 6, 2015 at 16:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.