sum fonction in gadfly

jean-jeanot jean.moser at neuf.fr
Sun Jun 25 07:27:19 EDT 2006


Thank you for your help. I have changed StringVar in IntVar and it
works! I didn't know that IntVar (as StringVa) were Tkinter Widget
variables! (It is important to read the doc!)  I made another mistake
in the value definition. I'have changed '%s' in %d  and it goes
perfectly well.
It could be useful for me to change of DB ? Which one ? Postgresql or
another ?

Jean Moser

Scott David Daniels a écrit :

> jean-jeanot wrote:
> > After creating the table  I create the variables with
> > varAmount = StringVar()
> Maybe you want to use DoubleVar or IntVar here?
>
> > With a function
> > def treatment ():
> >    requete = "insert into transactions ( date,amount,,....)
> > values(......) "% (varDate.get(),
> >    varAmount.get
> Or float(varAmount.get())  |
>     int(round(100 * float(varAmount.get()))) here
>
> > cur.execute ("select sum(amount) from transactions").I get
> > Sum.amout.transaction
> > =================
> > 100-10.5.......
> >
> > instead of 110.5
> >
> > It means that the select command does not add but concatenates the
> > different amounts. Why ?
> Sounds like you selected columns are strings, not numbers.
> Remember '123.5' + '-23' is '123.5-23', while 123.5 + -23 is 100.5
> You need the amount column of the transactions table in the gadfly
> database to be a numeric type, not a string type.
> 
> --Scott David Daniels
> scott.daniels at acm.org




More information about the Python-list mailing list