[Zope] ZSQL Method's Precision
David H
bluepaul at earthlink.net
Tue Oct 24 00:38:00 EDT 2006
Jason C. Leach wrote:
> Hi:
>
> In a PostgreSQL DB I have a Numeric data type with a precision of two
> decimal places. If I have 1.33 in as the result from my query, it's
> everything is good. However, if I have 1.30 it reduces the precision
> to one decimal place and I get 1.3. Not so good when dealing with
> currency ( I don't want to use the money data dype ).
>
> Any ideas on how I can get my ZSQL method to keep two decimal places?
>
> Thanks,
> Jason.
>
>
1.3 and 1.30 are different only in terms display and printing. One
approach can be wrapping your calls to the zsql in a python script that
applies formatting before returning the relavent results.
res = yourZSQL(params or request is all set up)
return "$%.2f" % res[0].yourAmountThatYouNeedToFORMAT
More information about the Zope
mailing list