PySqlite - division of real numbers without decimal fractions
Astley Le Jasper
Astley.lejasper at gmail.com
Fri Nov 7 06:07:19 EST 2008
On Nov 7, 6:36 am, Dan Bishop <danb... at yahoo.com> wrote:
> 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.
Hi,
But the calculations are being done within a sql statement within
SQLite?
([actual_price]-[recommended_price])/[recommended_price]
More information about the Python-list
mailing list