I'm using PyMySQL to ping a Database and get the values back. I am doing that like so:
cursor.execute(/*SQL Statement*/)
result = cursor.fetchone()
print (result)
I tested this and it works fine. Now the problem is I'm trying to get just the first element in the tuple result
and I tried doing this like so:
cursor.execute(/*SQL Statement*/)
result = cursor.fetchone()[0]
print (result)
However that just give me the following error:
Traceback (most recent call last):
File "myFile.py", line 20, in <module>
result = cursor.fetchone()[0]
KeyError: 0
I can't find much documentation on PyMySQL but that look right to me and it also makes sense so I'm not sure why it's not working. Here is the example I was following.