'How to get the Id of the row that contains a specific string SQL PyODBC

I am trying to get the id of the table row that contains a specific string, in my case a username.

cursor.execute("SELECT id FROM Users WHERE username = ?", user)
myresult = cursor.fetchall()
cursor.commit()
rez = myresult[-1][0]

I am getting this error: error

The result of the query looks like this

Error after using rez=cursor.fetchval() enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source