[PyGreSQL] Binding decimal.Decimal and sql arrays

raf raf at raf.org
Tue Sep 9 08:23:16 EDT 2008


Gregory Golberg wrote:

> Hi all,
> 
> 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...
> 
> The error I get is:
> 
> Native error: ("error 'do not know how to handle type <class 
> 'decimal.Decimal'>' in 'INIT'",)
> 
> -Greg

i just subscribed to this list to mention the same thing.

numeric/decimal objects really have to become Decimal. only
postgres real and double precision objects should become
python floats.

similarly, postgres arrays are not returned as python lists.
instead, they come back as string objects containing a
postgres-specific sql array string literal.

so, if you select a column of type integer[],
in python you get a string like '{1,2,3}' rather
than a list like [1,2,3].

ruby's postgres module does the same thing but perl's one
behaves correctly. can this be ficed as well?

a program demonstrating both bugs is attached.

cheers,
raf

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pygresql-type-bugs.py
Type: text/x-python
Size: 1064 bytes
Desc: not available
Url : http://mailman.vex.net/pipermail/pygresql/attachments/20080909/cc5102e1/attachment.py 


More information about the PyGreSQL mailing list