0

I'm having a problem with this MySQL Query, how can I fix that?

 valori = (message.from_user.id, message.from_user.username)
 verifica = "SELECT * FROM utenti WHERE ID = %s, Username = %s"
 cursor.execute(verifica, valori)

A sample of variable "valori":
(1062473636, 'Partizionare')

Error:

1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' Username = 'Partizionare'' at line 1
Traceback (most recent call last):
  File "/home/lello/.local/lib/python3.7/site-packages/pyrogram/dispatcher.py", line 217, in handler_worker
    await handler.callback(self.client, *args)
  File "/home/lello/Documents/Telegram/LelloDevBot/pyro.py", line 19, in start
    cursor.execute(verifica, valori)
  File "/home/lello/.local/lib/python3.7/site-packages/mysql/connector/cursor.py", line 551, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File "/home/lello/.local/lib/python3.7/site-packages/mysql/connector/connection.py", line 490, in cmd_query
    result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
  File "/home/lello/.local/lib/python3.7/site-packages/mysql/connector/connection.py", line 395, in _handle_result
    raise errors.get_exception(packet)
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' Username = 'Partizionare'' at line 1

1 Answer 1

1

There's no such thing as , in conditions, you mean AND.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I used to make query like in php.
Well, I'm just a little bit confused then. I haven't work with databases in a while. Anyway, thank you for the help.

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.