I am using mysql.connector in python to get a list of values from a database.
can you please help extract each value from the list separately
my code is as below
cnx = mysql.connector.connect(host=mysql_localhost, user=user, password=password, database=database)
cursor = cnx.cursor()
cursor.execute("select * from settings" )
results = cursor.fetchall()
print(results)
and the result I am getting is a list as follow
[(0, 3232235535L, 0, 12, 12.1, 22.5, 29.0)]
What I would like to do then is get each value (being integer or float) separately from the list above
Use a for loop:
for each in results[0]:
...
Or if you do want assign them to variables:
a, b, c, d, e, f, g = results[0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With