[PyGreSQL] DECIMAL to float, alternatives?

Christoph Zwerschke cito at online.de
Wed Jan 31 05:09:48 EST 2007


> when accessing PostgreSQL with pgdb, DECIMAL values in the database 
> are provided as floats in Python. Is it possible to get huge DECIMAL 
> values without losing precision?

Not directly, but you can of course cast the DECIMAL to TEXT in your
query, and then do with the string whatever you want in Python, e.g.
convert it to a Decimal. It has probably never been implemented since it
was only introduced in Python 2.4.

Maybe PyGreSQL should support the Decimal type? For DECIMAL (=NUMERIC)
with a scale of 0, we could also use long ints.

-- Chris


More information about the PyGreSQL mailing list