I am executing a mysql query in python using the MySQLdb package. The code looks something like this:
c=db.cursor()
c.execute("""select * from table""")
output = []
for row in c:
output.append(row[4])
where row[4]
contains a decimal value that I want to store in the output
list.
The problem is every value that I am getting looks like this: Decimal('XX.XX')
where all I want in the output
list is XX.XX. At the end of the script, my output
list looks like this:
[Decimal('10.02'), Decimal('20.24'), ...]
But I need it to just contain the numbers, like this:
[10.02, 20.24, ...]
How do I do that?
Thanks!
c=db.cursor()
c.execute("""select * from table""")
output = []
for row in c:
output.append(float(row[4]))