I have a query which returns a tuple and I'm trying to convert the first value from that tuple to a int but it always gives me this error:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple'
I don't understand why it's doing this because the returned values looks like this: [(25,)]
Here is the code:
cursor.execute("SELECT temp FROM temperatures WHERE datetimetest = ?", [datenow])
currentTemp = cursor.fetchall()
print(currentTemp) # this gives me [(25,)]
convertedTemp = int(currentTemp[0])
[(25,)]is a list containing a tuple (1 length tuple) OF an int. do not try to convert, just access it usingvar[0][0]