sqlite3 - Retrieve value from a fetchone() call in python 3 -
i new python , can not find answer question anywhere. unless don't understand answers given. have database cursor , execute command:
cmd = 'select value measurement measurement_location ?' crs.execute(cmd, [location_id]) print(crs.fetchone())
which prints:
{'value': 73.97486139568466}
i need use float 73.97.... in calculations compute average. problem can't figure out how pull float fetchone() return.
fetchone
returning dictionary each row mapping field name in result (only value
in example) value row. use can do
cmd = 'select value measurement measurement_location ?' crs.execute(cmd, [location_id]) row = crs.fetchone() print(row['value']) print(row['value'] * 100)
or whatever other things want result
Comments
Post a Comment