[PyGreSQL] Binding decimal.Decimal

Christoph Zwerschke cito at online.de
Mon Sep 15 05:46:32 EDT 2008


Gregory Golberg schrieb:
> It appears that binding decimal.Decimal does not work (have to use int 
> or float). Are there any plans to fix this? Using 'float' is wrong in 
> general, you don't want $10.37 to become 10.37000000001 for instance...

I've just created a patch to return Python Decimals for Postgres Numeric 
types (Py < 2.4 where decimal does not exist still returns floats).

@D'Arcy: Shall I check this in? This creates some backward 
incompatibility, since PyGres returned only floats before.

> Native error: ("error 'do not know how to handle type <class 
> 'decimal.Decimal'>' in 'INIT'",)

What exactly did you do to get this error? Pygres should play nice with 
Decimals, the only problem is that it treats them are binary floats.

-- Christoph


More information about the PyGreSQL mailing list