If you use your query to get only one value, you can just take the 0th index.
results = cursor.fetchall()
if the result has only one value, use results[0] . It should give you the meaning you seek. Sometimes we get a huge result when we run a query, in this situation we will have to iterate over the values ββand assign them to the list.
>>> result ('58',) >>> result[0] '58'
When you run a query for huge elements, you get the output of something like this when you use curosr.fetchall ()
(('58',),('50',),('10'),)
Use the following code to retrieve data in list format
>>> results=(('58',),('50',),('10'),) >>>[x[0] for x in results] --> code ['58', '50', '1']
source share