mysqldb cursor returning type along with result ?
Paul O'Sullivan
thesul1970 at googlemail.com
Sun Nov 29 08:14:43 EST 2009
Just taken to Python (2.5)and started to look at some DB cursor stuff
using MySQL. Anyway, after creating a query that in MySQL that has a
result set of decimals I find that the cursor in python after a
fetchall() returns a tuple that contains the following ::
((Decimal("101.10"),), (Decimal("99.32"),), (Decimal("97.95"),),
(Decimal("98.45"),), (Decimal("97.39"),), (Decimal("97.91"),), (Decimal
("98.08"),), (Decimal("97.73"),))
as such :
sum(result)
fails with "TypeError: unsupported operand type(s) for +: 'int' and
'tuple'"
How do I either get the resultset back as 'float' or convert the
returned tuple to 'floats'.?
Thanks, Newb.
More information about the Python-list
mailing list