I have a function to query DB and return a value like below
def find_dase(Plants):
conn = sqlite3.connect("dexro.db")
cursor = conn.cursor()
cursor.execute(("SELECT Years FROM Plants_no WHERE Plant=?"),(Plants,))
data = cursor.fetchall()
conn.close()
return data
when i execute this i am getting a list instead of the value
print(find_dase('dex'))
print(type(find_dase('dex')))
Output:
[('10',)]
<class 'list'>
How can i fetch only the integer value
.fetchone()instead.fetchall()?Years. So.fetchone()[0]