PySqlite - division of real numbers without decimal fractions

Dan Bishop danb_83 at yahoo.com
Fri Nov 7 06:36:17 CET 2008


On Nov 6, 3:46 pm, Astley Le Jasper <Astley.lejas... at gmail.com> wrote:
> I've been getting errors recently when using pysqlite. I've declared
> the table columns as real numbers to 2 decimal places (I'm dealing
> with money), but when doing division on two numbers that happen to
> have no decimal fractions, the results through pysqlite are coming
> through as integers. The funny thing is that when looking at the
> database using SQLite Manager or SQLite Pro the results there are
> displayed correctly. As a temporary fix I've had to multiply one of
> the numbers with 1.0 which has fixed it but I wonder if there is
> something else I'm doing wrong.

You're using old-style division.  Put the line "from __future__ import
division" in your script.



More information about the Python-list mailing list