Decimals again

6 views
Skip to first unread message

Michal Jursa

unread,
May 27, 2009, 7:53:01 AM5/27/09
to web...@googlegroups.com
Hi,
I know there were a lot of posts about pros and cons of implementing
DECIMAL type to DAL, but there is no result. As DECIMALs are really
important for me, I'd like to know if it will be included in DAL and if
yes, when ( i don't need exact date :) ). I can patch DAL to do it for
me on postgres now, but that's not solution for future and to say true,
I'm not happy with those solutions converting strings to decimals and
back etc. I think DECIMAL is standard type today and missing support in
sqlite should not be reason to stop implement it in DAL. If web2py aims
to be a real tool, then decimals are necessary. Noone makes real
projects on sqlite.

If I decide to stay with web2py, then I'd like to make this decision for
a bit longer term so I really need some info, coz i need to start
project :)

Michal

mdipierro

unread,
May 27, 2009, 8:27:56 AM5/27/09
to web2py Web Framework
In trunk this is already implemented

http://groups.google.com/group/web2py/browse_thread/thread/13d9e9fd7334b679

But it is experimental.

If you really want a date for a stable Decimal API in DAL, I can Say
July 31 but it may be done sooner.

Masssimo

Michal Jursa

unread,
May 27, 2009, 8:56:37 AM5/27/09
to web...@googlegroups.com
I know about trunk solution, but you've recently said you dont like to
implement decimals at all. Or may be I miunderstood you..:)

You think it is fine to start with trunk version and one day it will
become stable? Coz thats the only thing that really holds me back from
using web2py in 'real' world..:)

Michal

mdipierro

unread,
May 27, 2009, 9:17:12 AM5/27/09
to web2py Web Framework
That is not what I said. I said that it is not possible to implement
decimal in a way that behaves the same way with database backend
systems that support decimal nativly and those that do not.

My suggestion is, for now, use 'string' but convert the values to
decimal.Decimal() before using them in computations. This will give
you the precision you want.

Massimo

On May 27, 7:56 am, Michal Jursa <mic...@jursa.cz> wrote:
> I know about trunk solution, but you've recently said you dont like to
> implement decimals at all. Or may be I miunderstood you..:)
>
> You think it is fine to start with trunk version and one day it will
> become stable? Coz thats the only thing that really holds me back from
> using web2py in 'real' world..:)
>
> Michal
>
> mdipierro wrote:
> > In trunk this is already implemented
>
> >http://groups.google.com/group/web2py/browse_thread/thread/13d9e9fd73...

Michal Jursa

unread,
May 27, 2009, 10:08:15 AM5/27/09
to web...@googlegroups.com
Problem is I want to leave some logic also in db (triggers etc) and then
i come to trouble if i need to do some calculations in db. STR + STR in
db is not the right way to be done in SQL. I can handle these
str<->decimal conversions in any program, but i also need fully
functional database and it is not possible this way. This should be some
finacial stuff and i really don't want to do it like having prices in
cents or so. If this decimal trouble becomes a problem, i'll get
cherrypy myself again and start over from scratch, but i'd really like
to stay with web2py ..:)

Michal

Kuba Kucharski

unread,
May 27, 2009, 10:13:30 AM5/27/09
to web...@googlegroups.com
Stay with web2py! I have the same problem. I've decided to wait.
Decimal is a must. Web2py is not an enterprise framework until we have it ;)

--
Kuba

Michal Jursa

unread,
May 27, 2009, 10:16:41 AM5/27/09
to web...@googlegroups.com
+1 !! exactly ;)

mdipierro

unread,
May 27, 2009, 12:23:47 PM5/27/09
to web2py Web Framework
it would help if somebody explains to me how sqlalchemy handles it
with sqlite and systems that does not support it.

Kuba Kucharski

unread,
May 27, 2009, 12:52:43 PM5/27/09
to web...@googlegroups.com

'If you really need to store Decimals values, and do some op on them in the database, just do *not* use SQLite'

This is a quote from an sqlalchemy group..

We need an exception, an error occuring when trying to use decimal on sqlite or we implement decimal as float in sqlite(sqlalchemy default when not customized????) with a big red warning somewhere about loosing precision... like Michal said, nobody uses sqlite for financial modules/apps in production. Eventually the string solution but for sqlite only..

? Note that this is all AFAIK and I might be mistaken..

On May 27, 2009 6:24 PM, "mdipierro" <mdip...@cs.depaul.edu> wrote:


it would help if somebody explains to me how sqlalchemy handles it
with sqlite and systems that does not support it.

On May 27, 9:16 am, Michal Jursa <mic...@jursa.cz> wrote: > +1 !! exactly ;) > > Kuba Kucharski wro...

DenesL

unread,
May 27, 2009, 3:18:18 PM5/27/09
to web2py Web Framework
Lets document the support for decimal type in the available DBs (my $.
02):

p=precision, s=scale, [means optional]

---DB---- -----syntax----- --limits--- --dft--
MSSQL2005 decimal[(p[,s])] 0<=s<=p<=38 18,0
DB2/400 " 1<=s<=p<=31 5,0

Michal Jursa

unread,
May 27, 2009, 4:34:12 PM5/27/09
to web...@googlegroups.com
MYSQL
spec: For DECIMAL(M,D), the maximum M is 65
create: CREATE TABLE foo( bar decimal(10,2) )

POSTGRESQL
spec: DECIMAL(M,D), exact, no limit
create: CREATE TABLE foo( bar decimal(10,2) )



DenesL napsal(a):
Reply all
Reply to author
Forward
0 new messages