I try to make a query to the database through MySQL connector
query = ("SELECT * FROM taxe_client WHERE client_token = %s") print (clientToken) cursor.execute(query, (clientToken)) # смотрим количество возвращенных строк, если больше 0, то значит токен клиента в бд присутствует result = cursor.fetchall() colRows = len(result) if colRows > 0: # клиент в базе есть, берем данные for row in result: idClient = row[0] print(idClient) An exception occurs during the execution:
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check it out.
If you rewrite the query as
query = ("SELECT * FROM taxe_client WHERE client_token = '%s'") then the error disappears, although there is such a token in the database. If you rewrite the request again with an explicit indication of the token:
query = ("SELECT * FROM taxe_client WHERE client_token = '894d723f2daf0fb0fa99881152663691'") then idClient is displayed. What am I doing wrong?