Skip site navigation (1) Skip section navigation (2)

Re: Python interface and Money?

From: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
To: Joel Mc Graw <jmcgraw(at)databill(dot)com>
Cc: pgsql-interfaces(at)PostgreSQL(dot)org
Subject: Re: Python interface and Money?
Date: 2003-02-26 13:53:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
On Monday 22 October 2001 13:45, Joel Mc Graw wrote:
> I have a table that has a column of type money.  A query such as "select
> sum(document_amount) from foo" returns the correct result when executed
> from psql, yet the same query returns the wrong answer (it appears to be
> a rounding issue--something like "1234.9999999999...") when executed
> through PygreSQL.  Is there a workaround or a fix?

The problem is that Python doesn't (yet) have a native decimal type and so the 
closest thing we can convert to is float.  There have been attempts at a 
decimal type and at some point I will convert to one of them, hopefully the 
same one that Python chooses as a standard.

> While browsing the mailing list for an answer to this problem I found
> several references to the money type being deprecated.  Is that the
> problem?

There are people who want to remove it but I still think it serves a useful 
purpose.  I think that it needs to move to a 64 bit int and handle a lot more 
type conversions but I moved some stuff to numeric due to the limits and 
found a noticeable slowdown when working with lots of aggregates on it.  The 
int type is just more efficient.  I plan on making a contrib version of the 
type before it gets deleted if that is what is decided.

D'Arcy J.M. Cain <darcy(at){druid|vex}.net>   |  Democracy is three wolves                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.

In response to


pgsql-interfaces by date

Next:From: D'Arcy J.M. CainDate: 2003-02-26 13:57:07
Subject: Re: Python interface and Money?
Previous:From: Tom LaneDate: 2003-02-25 21:27:28
Subject: Re: debug a mess

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group