[PyGreSQL] Binding decimal.Decimal

Christoph Zwerschke cito at online.de
Tue Sep 16 04:51:47 EDT 2008


Gregory Golberg schrieb:
>> Ah, ok. This can be fixed quite easily, by adding decimal.Decimal to 
>> the list of number types in pgdb._quote.
>>   
> Is that a read-only field or can it be tweaked by a caller of pgdb?

You can add it in the pgdb.py module, or monkey-patch the function.

>> But complete support for decimal.Decimal, i.e. returning 
>> decimal.Decimal for numeric types, needs some additions to pgmodule.c 
> 
> This definitely needs doing, though, as using arbitrary-precision math 
> with databases is important.

Ok, but I'm waiting for D'Arcy's opinion before committing the patch, 
because of the compatibility issue. I'll make it configurable, but the 
question is whether we want Decimal to be the default for NUMERIC, or 
float (for backward compatibility's sake). I'm for the former, plus 
increasing the version number appropriately.

-- Christoph


More information about the PyGreSQL mailing list